aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2016-12-19 00:02:43 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2016-12-19 00:02:43 +0100
commit6cbc99d3ee1e7221f0b72f20012347c181902cfa (patch)
treeac5a2c7dc7167ae060e5e226d1e758411fbe1357 /org.eclipse.jgit
parenta498a2865e6cd55de4c027d019584205a72c07c6 (diff)
downloadjgit-6cbc99d3ee1e7221f0b72f20012347c181902cfa.tar.gz
jgit-6cbc99d3ee1e7221f0b72f20012347c181902cfa.zip
[infer] Fix resource leaks in DfsInserter
Bug: 509385 Change-Id: Id5dc40bb3fb9da97ea0795cca1f2bcdcde347767 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
index a5e920a75e..c179e77786 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
@@ -312,8 +312,7 @@ public class DfsInserter extends ObjectInserter {
}
DfsOutputStream os = db.writeFile(pack, INDEX);
- try {
- CountingOutputStream cnt = new CountingOutputStream(os);
+ try (CountingOutputStream cnt = new CountingOutputStream(os)) {
if (buf != null)
buf.writeTo(cnt, null);
else
@@ -321,7 +320,9 @@ public class DfsInserter extends ObjectInserter {
pack.addFileExt(INDEX);
pack.setFileSize(INDEX, cnt.getCount());
} finally {
- os.close();
+ if (buf != null) {
+ buf.close();
+ }
}
return packIndex;
}