From d7f4e6d1a1d74bcc8b0e86e0f6c4633f57159c24 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Sun, 20 Jan 2019 17:33:04 +0900 Subject: [PATCH] MergerTest: Open TestRepository in try-with-resource Change-Id: I1c4bd2fd5f0ad7112bd3ebe1506de3cf51231b36 Signed-off-by: David Pursehouse --- .../tst/org/eclipse/jgit/merge/MergerTest.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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); } }