From 325cb35ccd6108eaf9e6c3ec6343ca6988f10a21 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Tue, 20 Dec 2016 01:08:38 +0100 Subject: [PATCH] [infer] Fix resource leak in ObjectChecker Bug: 509385 Change-Id: I6b6ff5b721d959eb0708003a40c8f97d6826ac46 Signed-off-by: Matthias Sohn --- org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java index 0b5efd77d..feecbd81c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java @@ -709,11 +709,12 @@ public class ObjectChecker { return ptr; } - @SuppressWarnings("resource") @Nullable private ObjectId idFor(int objType, byte[] raw) { if (skipList != null) { - return new ObjectInserter.Formatter().idFor(objType, raw); + try (ObjectInserter.Formatter fmt = new ObjectInserter.Formatter()) { + return fmt.idFor(objType, raw); + } } return null; }