From 75d9b31f14d6226a535a80c05cffda29e55d2ceb Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Wed, 17 Jul 2013 12:19:12 -0700 Subject: 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 Change-Id: I594dcdf366200b802e13e5a645fe06597feb7bb4 Signed-off-by: Jonathan Nieder --- .../src/org/eclipse/jgit/archive/TarFormat.java | 7 +++++-- .../src/org/eclipse/jgit/archive/ZipFormat.java | 7 +++++-- 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 { } entry.setSize(loader.getSize()); out.putArchiveEntry(entry); - loader.copyTo(out); - out.closeArchiveEntry(); + try { + loader.copyTo(out); + } finally { + out.closeArchiveEntry(); + } } public Iterable 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 { } entry.setSize(loader.getSize()); out.putArchiveEntry(entry); - loader.copyTo(out); - out.closeArchiveEntry(); + try { + loader.copyTo(out); + } finally { + out.closeArchiveEntry(); + } } public Iterable suffixes() { -- cgit v1.2.3