From 62637584d87cbb0d83263d9c541827c6c99a69de Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Fri, 5 Feb 2016 11:42:44 +0900 Subject: [PATCH] TreeWalkJava7Test: Open TreeWalk in try-with-resource Change-Id: I99a483c482b5395653b0d57b368ec1b5fdba450c Signed-off-by: David Pursehouse --- .../jgit/treewalk/TreeWalkJava7Test.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/TreeWalkJava7Test.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/TreeWalkJava7Test.java index 1328b38e6..ba8f194e3 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/TreeWalkJava7Test.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/TreeWalkJava7Test.java @@ -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()); + } } }