]> source.dussan.org Git - jgit.git/commitdiff
TreeWalkJava7Test: Open TreeWalk in try-with-resource 59/65959/1
authorDavid Pursehouse <david.pursehouse@sonymobile.com>
Fri, 5 Feb 2016 02:42:44 +0000 (11:42 +0900)
committerDavid Pursehouse <david.pursehouse@sonymobile.com>
Fri, 5 Feb 2016 02:42:44 +0000 (11:42 +0900)
Change-Id: I99a483c482b5395653b0d57b368ec1b5fdba450c
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/TreeWalkJava7Test.java

index 1328b38e637fdbdc974d8c1086e5bd830b45f74e..ba8f194e3fbda84b62c9f2c782cf62ff716b5937 100644 (file)
@@ -60,13 +60,14 @@ public class TreeWalkJava7Test extends RepositoryTestCase {
                assertTrue(fs.supportsSymlinks());
                writeTrashFile("target/data", "targetdata");
                fs.createSymLink(new File(trash, "link"), "target");
-               TreeWalk tw = new TreeWalk(db);
-               tw.setRecursive(true);
-               tw.addTree(new FileTreeIterator(db));
-               assertTrue(tw.next());
-               assertEquals("link", tw.getPathString());
-               assertTrue(tw.next());
-               assertEquals("target/data", tw.getPathString());
-               assertFalse(tw.next());
+               try (TreeWalk tw = new TreeWalk(db)) {
+                       tw.setRecursive(true);
+                       tw.addTree(new FileTreeIterator(db));
+                       assertTrue(tw.next());
+                       assertEquals("link", tw.getPathString());
+                       assertTrue(tw.next());
+                       assertEquals("target/data", tw.getPathString());
+                       assertFalse(tw.next());
+               }
        }
 }