From 581698331a0e80eb02fdd7549cfce1c0e6f9ac87 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 1 Oct 2015 15:10:22 +0900 Subject: [PATCH] FanoutBucket: Create ObjectInserter.Formatter in try-with-resource To prevent potential resource leak. Change-Id: Ife09be2822bc476199f10da8d1eb7ccc8da05b79 Signed-off-by: David Pursehouse --- org.eclipse.jgit/src/org/eclipse/jgit/notes/FanoutBucket.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/notes/FanoutBucket.java b/org.eclipse.jgit/src/org/eclipse/jgit/notes/FanoutBucket.java index ea904cd1d..79fbb09ec 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/notes/FanoutBucket.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/notes/FanoutBucket.java @@ -260,8 +260,8 @@ class FanoutBucket extends InMemoryNoteBucket { } ObjectId getTreeId() { - try { - return new ObjectInserter.Formatter().idFor(build(false, null)); + try (ObjectInserter.Formatter f = new ObjectInserter.Formatter()) { + return f.idFor(build(false, null)); } catch (IOException e) { // should never happen as we are not inserting throw new RuntimeException(e);