summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.archive
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2013-07-17 12:19:12 -0700
committerJonathan Nieder <jrn@google.com>2013-07-17 12:21:56 -0700
commit75d9b31f14d6226a535a80c05cffda29e55d2ceb (patch)
tree712573cb8c84b8436aaac836ce72d86b3b3d5ff2 /org.eclipse.jgit.archive
parent459fd7d4bb659d021a511c3c9eea0af7dab21b3d (diff)
downloadjgit-75d9b31f14d6226a535a80c05cffda29e55d2ceb.tar.gz
jgit-75d9b31f14d6226a535a80c05cffda29e55d2ceb.zip
Close unfinished archive entries on error
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>
Diffstat (limited to 'org.eclipse.jgit.archive')
-rw-r--r--org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java7
-rw-r--r--org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java7
2 files changed, 10 insertions, 4 deletions
diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
index 23f4beda14..cd98c03393 100644
--- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
+++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
@@ -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() {
diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java
index 00c962bc98..be7264bd8b 100644
--- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java
+++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java
@@ -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() {