summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/ForPathTest.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/ForPathTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/ForPathTest.java
index eaee8bb4b9..3d9af35a71 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/ForPathTest.java
+++ b/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;
}
}