Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2016-12-19 07:38:41 +0000
committerMatthias Sohn2016-12-19 07:38:41 +0000
commitf30fe13ac94df9de77c18813f41c29fe7f55a44f (patch)
tree9cf1064995717dab276ccfa21c3dda013976b95b
parent6cbc99d3ee1e7221f0b72f20012347c181902cfa (diff)
downloadjgit-f30fe13ac94df9de77c18813f41c29fe7f55a44f.tar.gz
jgit-f30fe13ac94df9de77c18813f41c29fe7f55a44f.tar.xz
jgit-f30fe13ac94df9de77c18813f41c29fe7f55a44f.zip
[infer] Fix a resource leak in PackWriter
Bug: 509385 Change-Id: Ic8a82895fa39be73f1bd8427cfe9437be6fc4e3e Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
index 691867aba8..8b4d2e6d35 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
@@ -1597,14 +1597,15 @@ public class PackWriter implements AutoCloseable {
}
}
- TemporaryBuffer.Heap delta = delta(otp);
- out.writeHeader(otp, delta.length());
+ try (TemporaryBuffer.Heap delta = delta(otp)) {
+ out.writeHeader(otp, delta.length());
- Deflater deflater = deflater();
- deflater.reset();
- DeflaterOutputStream dst = new DeflaterOutputStream(out, deflater);
- delta.writeTo(dst, null);
- dst.finish();
+ Deflater deflater = deflater();
+ deflater.reset();
+ DeflaterOutputStream dst = new DeflaterOutputStream(out, deflater);
+ delta.writeTo(dst, null);
+ dst.finish();
+ }
typeStats.cntDeltas++;
typeStats.deltaBytes += out.length() - otp.getOffset();
}

Back to the top