diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java index 335a8ca1a..f6fc00ce4 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java @@ -1360,14 +1360,15 @@ public class MergerTest extends RepositoryTestCase { } private String readBlob(ObjectId treeish, String path) throws Exception { - TestRepository tr = new TestRepository<>(db); - RevWalk rw = tr.getRevWalk(); - RevTree tree = rw.parseTree(treeish); - RevObject obj = tr.get(tree, path); - if (obj == null) { - return null; + try (TestRepository tr = new TestRepository<>(db)) { + RevWalk rw = tr.getRevWalk(); + RevTree tree = rw.parseTree(treeish); + RevObject obj = tr.get(tree, path); + if (obj == null) { + return null; + } + return new String( + rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(), UTF_8); } - return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(), - UTF_8); } }