aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Nieder2013-09-23 20:06:18 (EDT)
committerJonathan Nieder2013-09-23 20:31:27 (EDT)
commit8a51c4453df0015ee0b77076ffb34eecdfcc7ec6 (patch)
tree67213a45f38d8052d39634ada1a8de541abd4f50
parent570bba5e7acb08df827655c31045bfe9cde9d856 (diff)
downloadjgit-8a51c4453df0015ee0b77076ffb34eecdfcc7ec6.zip
jgit-8a51c4453df0015ee0b77076ffb34eecdfcc7ec6.tar.gz
jgit-8a51c4453df0015ee0b77076ffb34eecdfcc7ec6.tar.bz2
Do not close ArchiveOutputStream on errorrefs/changes/09/16709/4
If we encounter an I/O error while writing an archive (for example due to the reader of an HTTP stream closing the connection), the result is an archive with unclosed entries, causing TarArchiveOutputStream.finish() to throw IOException("This archives contains unclosed entries"), hiding the IOException that caused the early termination. The unclosed entries are fine: the same exception that occured in the first place will probably prevent closing the entries before finishing this partial archive that should be discarded anyway. It would be nicer to call TarArchiveOutputStream.finish and leave the underlying OutputStream unclosed --- all callers close it already --- but that would be a more invasive change so we hold off for now. Change-Id: I328ced19aa8a1888e5353cdbb6106a85fd72d5d7 Signed-off-by: Jonathan Nieder <jrn@google.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java
index e8e4ffd..42d0f65 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java
@@ -111,7 +111,6 @@ public class ArchiveCommand extends GitCommand<OutputStream> {
* for (...) {
* format.putEntry(out, path, mode, repo.open(objectId));
* }
- * } finally {
* out.close();
* }
*
@@ -287,8 +286,9 @@ public class ArchiveCommand extends GitCommand<OutputStream> {
walk.getObjectId(idBuf, 0);
fmt.putEntry(outa, name, mode, reader.open(idBuf));
}
- } finally {
outa.close();
+ } finally {
+ out.close();
}
return out;
} catch (IOException e) {