summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2016-02-15 17:09:09 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2016-02-15 17:09:09 +0900
commit430b777830bad84605afdff48baa9f65bf773014 (patch)
tree171f002b65ed2c40947d5fa3e199bbd45e64d1ae
parent130cf0d61aba0eff821c001b42bf87e50f590d54 (diff)
downloadjgit-430b777830bad84605afdff48baa9f65bf773014.tar.gz
jgit-430b777830bad84605afdff48baa9f65bf773014.zip
ForPathTest: Open TreeWalk in try-with-resource
Change-Id: Ie4d0eb9c0fe1d8b8f41da161e701137cd7dd178f Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
-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;
}
}