From e4433e5e37b827aa6af3320635c8af0877cd4a60 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Wed, 1 Apr 2015 12:57:06 -0700 Subject: [PATCH] Fix overflow stream leak during merge conflicts When reading back from an overflowed TemporaryBuffer the InputStream must be closed to close the FileInputStream that is reading from the backing file. Change-Id: Id83d8f16f5b2c2618a9f841ec3508508455a6ae1 --- .../src/org/eclipse/jgit/merge/ResolveMerger.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java index 1ddac1b57..98c8342de 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java @@ -810,8 +810,9 @@ public class ResolveMerger extends ThreeWayMerger { new MergeFormatter().formatMerge(buf, result, Arrays.asList(commitNames), CHARACTER_ENCODING); buf.close(); - return getObjectInserter().insert(OBJ_BLOB, buf.length(), - buf.openInputStream()); + try (InputStream in = buf.openInputStream()) { + return getObjectInserter().insert(OBJ_BLOB, buf.length(), in); + } } finally { buf.destroy(); }