diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/TreeFilterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/TreeFilterTest.java index 09007e7cb..c3423b6fb 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/TreeFilterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/TreeFilterTest.java @@ -55,9 +55,10 @@ import org.junit.Test; public class TreeFilterTest extends RepositoryTestCase { @Test public void testALL_IncludesAnything() throws Exception { - final TreeWalk tw = new TreeWalk(db); - tw.addTree(new EmptyTreeIterator()); - assertTrue(TreeFilter.ALL.include(tw)); + try (final TreeWalk tw = new TreeWalk(db)) { + tw.addTree(new EmptyTreeIterator()); + assertTrue(TreeFilter.ALL.include(tw)); + } } @Test @@ -72,16 +73,18 @@ public class TreeFilterTest extends RepositoryTestCase { @Test public void testNotALL_IncludesNothing() throws Exception { - final TreeWalk tw = new TreeWalk(db); - tw.addTree(new EmptyTreeIterator()); - assertFalse(TreeFilter.ALL.negate().include(tw)); + try (final TreeWalk tw = new TreeWalk(db)) { + tw.addTree(new EmptyTreeIterator()); + assertFalse(TreeFilter.ALL.negate().include(tw)); + } } @Test public void testANY_DIFF_IncludesSingleTreeCase() throws Exception { - final TreeWalk tw = new TreeWalk(db); - tw.addTree(new EmptyTreeIterator()); - assertTrue(TreeFilter.ANY_DIFF.include(tw)); + try (final TreeWalk tw = new TreeWalk(db)) { + tw.addTree(new EmptyTreeIterator()); + assertTrue(TreeFilter.ANY_DIFF.include(tw)); + } } @Test