summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2016-12-18 01:42:24 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2016-12-18 13:49:37 +0100
commit1779fb4a57375bbb3e92246a47c63a846af90491 (patch)
treef7a5f8518559a8ae3b12d1c293ffa930872f70d7
parentaa199ff648a3b683ce128c3293d4f529bac6864b (diff)
downloadjgit-1779fb4a57375bbb3e92246a47c63a846af90491.tar.gz
jgit-1779fb4a57375bbb3e92246a47c63a846af90491.zip
[infer] Fix resource leak in DirCache
Bug: 509385 Change-Id: I5f914c910ef3a7583594fb31c7757d3dddf6a05e Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
index eeaab11afa..b0cf8be076 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
@@ -634,9 +634,9 @@ public class DirCache {
public void write() throws IOException {
final LockFile tmp = myLock;
requireLocked(tmp);
- try {
- writeTo(liveFile.getParentFile(),
- new BufferedOutputStream(tmp.getOutputStream()));
+ try (OutputStream o = tmp.getOutputStream();
+ OutputStream bo = new BufferedOutputStream(o)) {
+ writeTo(liveFile.getParentFile(), bo);
} catch (IOException err) {
tmp.unlock();
throw err;