From f7a3643fb8c977739af928f2aafc9eeb01a83abc Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Fri, 12 Feb 2016 14:02:49 +0900 Subject: [PATCH] PathSuffixFilterTest: Open TreeWalk in try-with-resource Change-Id: If0ee71f09a5464e27f0496dac364f8f9bb015eb6 Signed-off-by: David Pursehouse --- .../treewalk/filter/PathSuffixFilterTest.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/PathSuffixFilterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/PathSuffixFilterTest.java index d871c5ec10..3885c41688 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/PathSuffixFilterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/PathSuffixFilterTest.java @@ -113,15 +113,16 @@ public class PathSuffixFilterTest extends RepositoryTestCase { private List getMatchingPaths(String suffixFilter, final ObjectId treeId, boolean recursiveWalk) throws IOException { - final TreeWalk tw = new TreeWalk(db); - tw.setFilter(PathSuffixFilter.create(suffixFilter)); - tw.setRecursive(recursiveWalk); - tw.addTree(treeId); - - List paths = new ArrayList(); - while (tw.next()) - paths.add(tw.getPathString()); - return paths; + try (final TreeWalk tw = new TreeWalk(db)) { + tw.setFilter(PathSuffixFilter.create(suffixFilter)); + tw.setRecursive(recursiveWalk); + tw.addTree(treeId); + + List paths = new ArrayList(); + while (tw.next()) + paths.add(tw.getPathString()); + return paths; + } } } -- 2.39.5