From 3f791820813c4415f5de8a02b326631d0fb0f284 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Thu, 2 Apr 2015 01:30:14 +0200 Subject: [PATCH] Fix resource leak in ChangeIdUtil Change-Id: I5cb3e9c7e167248697932933eef925c446514683 Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/util/ChangeIdUtil.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java index 35850dcaa..35fc99e54 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java @@ -115,8 +115,10 @@ public class ChangeIdUtil { b.append(committer.toExternalString()); b.append("\n\n"); //$NON-NLS-1$ b.append(cleanMessage); - return new ObjectInserter.Formatter().idFor(Constants.OBJ_COMMIT, // - b.toString().getBytes(Constants.CHARACTER_ENCODING)); + try (ObjectInserter f = new ObjectInserter.Formatter()) { + return f.idFor(Constants.OBJ_COMMIT, // + b.toString().getBytes(Constants.CHARACTER_ENCODING)); + } } private static final Pattern issuePattern = Pattern