Browse Source

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>
stable-3.1
Jonathan Nieder 11 years ago
parent
commit
75d9b31f14
  1. 3
      org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
  2. 3
      org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java

3
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java

@ -93,9 +93,12 @@ public class TarFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
}
entry.setSize(loader.getSize());
out.putArchiveEntry(entry);
try {
loader.copyTo(out);
} finally {
out.closeArchiveEntry();
}
}
public Iterable<String> suffixes() {
return SUFFIXES;

3
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java

@ -82,9 +82,12 @@ public class ZipFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
}
entry.setSize(loader.getSize());
out.putArchiveEntry(entry);
try {
loader.copyTo(out);
} finally {
out.closeArchiveEntry();
}
}
public Iterable<String> suffixes() {
return SUFFIXES;

Loading…
Cancel
Save