Browse Source

ForPathTest: Open TreeWalk in try-with-resource

Change-Id: Ie4d0eb9c0fe1d8b8f41da161e701137cd7dd178f
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
stable-4.2
David Pursehouse 9 years ago
parent
commit
430b777830
  1. 23
      org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/ForPathTest.java

23
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/ForPathTest.java

@ -84,21 +84,22 @@ public class ForPathTest extends RepositoryTestCase {
ObjectId tree = tree0.writeTree(oi);
// Find the directories that were implicitly created above.
TreeWalk tw = new TreeWalk(or);
tw.addTree(tree);
ObjectId a = null;
ObjectId aSlashC = null;
while (tw.next()) {
if (tw.getPathString().equals("a")) {
a = tw.getObjectId(0);
tw.enterSubtree();
while (tw.next()) {
if (tw.getPathString().equals("a/c")) {
aSlashC = tw.getObjectId(0);
break;
try (TreeWalk tw = new TreeWalk(or)) {
tw.addTree(tree);
while (tw.next()) {
if (tw.getPathString().equals("a")) {
a = tw.getObjectId(0);
tw.enterSubtree();
while (tw.next()) {
if (tw.getPathString().equals("a/c")) {
aSlashC = tw.getObjectId(0);
break;
}
}
break;
}
break;
}
}

Loading…
Cancel
Save