Browse Source

MergerTest: Open TestRepository in try-with-resource

Change-Id: I1c4bd2fd5f0ad7112bd3ebe1506de3cf51231b36
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.4
David Pursehouse 6 years ago
parent
commit
d7f4e6d1a1
  1. 17
      org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java

17
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);
}
}

Loading…
Cancel
Save