]> source.dussan.org Git - jgit.git/commitdiff
[infer] Fix resource leak in ObjectChecker 46/87446/2
authorMatthias Sohn <matthias.sohn@sap.com>
Tue, 20 Dec 2016 00:08:38 +0000 (01:08 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 20 Dec 2016 23:50:21 +0000 (00:50 +0100)
Bug: 509385
Change-Id: I6b6ff5b721d959eb0708003a40c8f97d6826ac46
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java

index 0b5efd77d45f602e21aeb739f5475693e5f23ebc..feecbd81c0e81b51b1e7fa74253150894907e0b3 100644 (file)
@@ -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;
        }