]> source.dussan.org Git - jgit.git/commitdiff
Close unfinished archive entries on error 28/14628/1
authorJonathan Nieder <jrn@google.com>
Wed, 17 Jul 2013 19:19:12 +0000 (12:19 -0700)
committerJonathan Nieder <jrn@google.com>
Wed, 17 Jul 2013 19:21:56 +0000 (12:21 -0700)
Otherwise the underlying error is hidden by an "IOException: This
archives contains unclosed entries." when jgit tries to close the
archive.

Reported-by: Dave Borowitz <dborowitz@google.com>
Change-Id: I594dcdf366200b802e13e5a645fe06597feb7bb4
Signed-off-by: Jonathan Nieder <jrn@google.com>
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java

index 23f4beda1448961a81fbc6333c086ac38f9bb7c5..cd98c03393f0f10b407578aa022b03007899a286 100644 (file)
@@ -93,8 +93,11 @@ public class TarFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
                }
                entry.setSize(loader.getSize());
                out.putArchiveEntry(entry);
-               loader.copyTo(out);
-               out.closeArchiveEntry();
+                try {
+                       loader.copyTo(out);
+               } finally {
+                       out.closeArchiveEntry();
+               }
        }
 
        public Iterable<String> suffixes() {
index 00c962bc9827f71beef9498cb4459420d8d8fcd7..be7264bd8b386e3fa3d50ea283e7912c717f6d31 100644 (file)
@@ -82,8 +82,11 @@ public class ZipFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
                }
                entry.setSize(loader.getSize());
                out.putArchiveEntry(entry);
-               loader.copyTo(out);
-               out.closeArchiveEntry();
+               try {
+                       loader.copyTo(out);
+               } finally {
+                       out.closeArchiveEntry();
+               }
        }
 
        public Iterable<String> suffixes() {