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

index 09007e7cb56e0698cd99c3c1ef3299e206c1d625..c3423b6fb10938c4a5c2fefc61fd35b9e154be71 100644 (file)
@@ -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