From 1779fb4a57375bbb3e92246a47c63a846af90491 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sun, 18 Dec 2016 01:42:24 +0100 Subject: [PATCH] [infer] Fix resource leak in DirCache Bug: 509385 Change-Id: I5f914c910ef3a7583594fb31c7757d3dddf6a05e Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/dircache/DirCache.java | 6 +++--- 1 file 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 eeaab11af..b0cf8be07 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;