diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java index ab7633281..b43b9b178 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java @@ -268,8 +268,7 @@ public class DfsPackCompactor { pc.setReuseDeltas(true); pc.setReuseObjects(true); - PackWriter pw = new PackWriter(pc, ctx); - try { + try (PackWriter pw = new PackWriter(pc, ctx)) { pw.setDeltaBaseAsOffset(true); pw.setReuseDeltaCommits(false); @@ -285,8 +284,6 @@ public class DfsPackCompactor { writeIndex(objdb, outDesc, pw); PackStatistics stats = pw.getStatistics(); - pw.close(); - pw = null; outDesc.setPackStats(stats); newStats = stats; @@ -296,10 +293,6 @@ public class DfsPackCompactor { objdb.rollbackPack(Collections.singletonList(outDesc)); } } - } finally { - if (pw != null) { - pw.close(); - } } }