From c845db3ec2b73fcb91627a591344174a50d956cb Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 27 Apr 2020 15:15:11 +0200 Subject: [PATCH] RefTreeBatch: fix unclosed resource warning Change-Id: I7d630d11d3ef2ff2b74ec7a7018760b7b4931ad2 Signed-off-by: Matthias Sohn --- .../eclipse/jgit/internal/storage/reftree/RefTreeBatch.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java index c5560b97b..b154b95ad 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java @@ -88,8 +88,9 @@ class RefTreeBatch extends BatchRefUpdate { tree = RefTree.read(rw.getObjectReader(), c.getTree()); } else { parentCommitId = ObjectId.zeroId(); - parentTreeId = new ObjectInserter.Formatter() - .idFor(OBJ_TREE, new byte[] {}); + try (ObjectInserter.Formatter fmt = new ObjectInserter.Formatter()) { + parentTreeId = fmt.idFor(OBJ_TREE, new byte[] {}); + } tree = RefTree.newEmptyTree(); } }