aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2019-10-15 08:52:39 +0200
committerThomas Wolf <thomas.wolf@paranor.ch>2019-10-15 13:24:30 +0200
commit563ec9ecb671d5b329a71c08ff49e9acd4fa0b33 (patch)
tree51ea209bbc981adb2364798e6fbec892cc23840c /org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes
parent5e0eca69432c4a382ab6b0d08728f52b1e305a30 (diff)
downloadjgit-563ec9ecb671d5b329a71c08ff49e9acd4fa0b33.tar.gz
jgit-563ec9ecb671d5b329a71c08ff49e9acd4fa0b33.zip
Close TreeWalks in tests
Note that TreeWalk.forPath() needs not be closed; the ObjectReader _is_ closed when that method returns. Change-Id: I6e022e4a2fde0c88d610a82de092ea541b33f75c Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesHandlerTest.java529
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeDirCacheIteratorTest.java109
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeWorkingTreeIteratorTest.java99
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java6
4 files changed, 390 insertions, 353 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesHandlerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesHandlerTest.java
index 5868482c88..adc64d227e 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesHandlerTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesHandlerTest.java
@@ -69,83 +69,90 @@ public class AttributesHandlerTest extends RepositoryTestCase {
private static final FileMode F = FileMode.REGULAR_FILE;
- private TreeWalk walk;
-
@Test
public void testExpandNonMacro1() throws Exception {
setupRepo(null, null, null, "*.txt text");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs("text"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs("text"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
public void testExpandNonMacro2() throws Exception {
setupRepo(null, null, null, "*.txt -text");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs("-text"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs("-text"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
public void testExpandNonMacro3() throws Exception {
setupRepo(null, null, null, "*.txt !text");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs(""));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs(""));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
public void testExpandNonMacro4() throws Exception {
setupRepo(null, null, null, "*.txt text=auto");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs("text=auto"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs("text=auto"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
public void testExpandBuiltInMacro1() throws Exception {
setupRepo(null, null, null, "*.txt binary");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs("binary -diff -merge -text"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt",
+ attrs("binary -diff -merge -text"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
public void testExpandBuiltInMacro2() throws Exception {
setupRepo(null, null, null, "*.txt -binary");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs("-binary diff merge text"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt",
+ attrs("-binary diff merge text"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
public void testExpandBuiltInMacro3() throws Exception {
setupRepo(null, null, null, "*.txt !binary");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs(""));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs(""));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -153,44 +160,48 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo(
"[attr]foo a -b !c d=e", null, null, "*.txt foo");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs("foo a -b d=e"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs("foo a -b d=e"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
public void testCustomGlobalMacro2() throws Exception {
setupRepo("[attr]foo a -b !c d=e", null, null, "*.txt -foo");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs("-foo -a b d=e"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs("-foo -a b d=e"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
public void testCustomGlobalMacro3() throws Exception {
setupRepo("[attr]foo a -b !c d=e", null, null, "*.txt !foo");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs(""));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs(""));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
public void testCustomGlobalMacro4() throws Exception {
setupRepo("[attr]foo a -b !c d=e", null, null, "*.txt foo=bar");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs("foo=bar a -b d=bar"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs("foo=bar a -b d=bar"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -198,11 +209,12 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo("[attr]foo bar1",
"[attr]foo bar2", null, "*.txt foo");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs("foo bar2"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs("foo bar2"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -211,12 +223,13 @@ public class AttributesHandlerTest extends RepositoryTestCase {
null,
"[attr]foo bar3", "*.txt foo");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs("foo bar3"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs("foo bar3"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -224,12 +237,13 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo("[attr]foo bar1",
"[attr]foo bar2", "[attr]foo bar3", "*.txt foo");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs("foo bar2"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs("foo bar2"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -238,11 +252,12 @@ public class AttributesHandlerTest extends RepositoryTestCase {
"[attr]foo x bar -foo",
null, null, "*.txt foo");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs("foo x bar"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs("foo x bar"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -250,11 +265,12 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo(
"[attr]foo x -bar\n[attr]bar y -foo", null, null, "*.txt foo");
- walk = beginWalk();
- assertIteration(D, "sub");
- assertIteration(F, "sub/.gitattributes");
- assertIteration(F, "sub/a.txt", attrs("foo x -bar -y"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/.gitattributes");
+ assertIteration(walk, F, "sub/a.txt", attrs("foo x -bar -y"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -266,23 +282,30 @@ public class AttributesHandlerTest extends RepositoryTestCase {
// apply to any of the files here. It would match for a
// further subdirectory sub/sub. The sub/ rules must match
// only for directories.
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "sub", attrs("global"));
- assertIteration(F, "sub/.gitattributes", attrs("init top_sub"));
- assertIteration(F, "sub/a.txt", attrs("init foo top top_sub"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "sub", attrs("global"));
+ assertIteration(walk, F, "sub/.gitattributes",
+ attrs("init top_sub"));
+ assertIteration(walk, F, "sub/a.txt",
+ attrs("init foo top top_sub"));
+ assertFalse("Not all files tested", walk.next());
+ }
// All right, let's see that they *do* apply in sub/sub:
writeTrashFile("sub/sub/b.txt", "b");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "sub", attrs("global"));
- assertIteration(F, "sub/.gitattributes", attrs("init top_sub"));
- assertIteration(F, "sub/a.txt", attrs("init foo top top_sub"));
- assertIteration(D, "sub/sub", attrs("init subsub2 top_sub global"));
- assertIteration(F, "sub/sub/b.txt",
- attrs("init foo subsub top top_sub"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "sub", attrs("global"));
+ assertIteration(walk, F, "sub/.gitattributes",
+ attrs("init top_sub"));
+ assertIteration(walk, F, "sub/a.txt",
+ attrs("init foo top top_sub"));
+ assertIteration(walk, D, "sub/sub",
+ attrs("init subsub2 top_sub global"));
+ assertIteration(walk, F, "sub/sub/b.txt",
+ attrs("init foo subsub top top_sub"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -293,16 +316,17 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/b.jar", "bj");
writeTrashFile("sub/b.xml", "bx");
// On foo.xml/bar.jar we must not have 'xml'
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "foo.xml", attrs("xml"));
- assertIteration(F, "foo.xml/bar.jar", attrs("jar"));
- assertIteration(F, "foo.xml/bar.xml", attrs("xml"));
- assertIteration(D, "sub");
- assertIteration(F, "sub/a.txt");
- assertIteration(F, "sub/b.jar", attrs("jar"));
- assertIteration(F, "sub/b.xml", attrs("xml"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "foo.xml", attrs("xml"));
+ assertIteration(walk, F, "foo.xml/bar.jar", attrs("jar"));
+ assertIteration(walk, F, "foo.xml/bar.xml", attrs("xml"));
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/a.txt");
+ assertIteration(walk, F, "sub/b.jar", attrs("jar"));
+ assertIteration(walk, F, "sub/b.xml", attrs("xml"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -314,18 +338,19 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/b.jar", "bj");
writeTrashFile("sub/b.xml", "bx");
writeTrashFile("sub/foo/b.jar", "bf");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "foo", attrs("xml"));
- assertIteration(F, "foo/bar.jar", attrs("jar"));
- assertIteration(F, "foo/bar.xml");
- assertIteration(D, "sub");
- assertIteration(F, "sub/a.txt");
- assertIteration(F, "sub/b.jar", attrs("jar"));
- assertIteration(F, "sub/b.xml");
- assertIteration(D, "sub/foo", attrs("sub xml"));
- assertIteration(F, "sub/foo/b.jar", attrs("jar"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "foo", attrs("xml"));
+ assertIteration(walk, F, "foo/bar.jar", attrs("jar"));
+ assertIteration(walk, F, "foo/bar.xml");
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/a.txt");
+ assertIteration(walk, F, "sub/b.jar", attrs("jar"));
+ assertIteration(walk, F, "sub/b.xml");
+ assertIteration(walk, D, "sub/foo", attrs("sub xml"));
+ assertIteration(walk, F, "sub/foo/b.jar", attrs("jar"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -337,18 +362,19 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/b.xml", "bx");
writeTrashFile("sub/foo/b.jar", "bf");
// On foo.xml/bar.jar we must not have 'xml'
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "foo");
- assertIteration(F, "foo/bar.jar", attrs("jar xml"));
- assertIteration(F, "foo/bar.xml", attrs("xml"));
- assertIteration(D, "sub");
- assertIteration(F, "sub/a.txt");
- assertIteration(F, "sub/b.jar", attrs("jar"));
- assertIteration(F, "sub/b.xml");
- assertIteration(D, "sub/foo");
- assertIteration(F, "sub/foo/b.jar", attrs("jar"));
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "foo");
+ assertIteration(walk, F, "foo/bar.jar", attrs("jar xml"));
+ assertIteration(walk, F, "foo/bar.xml", attrs("xml"));
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/a.txt");
+ assertIteration(walk, F, "sub/b.jar", attrs("jar"));
+ assertIteration(walk, F, "sub/b.xml");
+ assertIteration(walk, D, "sub/foo");
+ assertIteration(walk, F, "sub/foo/b.jar", attrs("jar"));
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -357,27 +383,29 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/a.txt", "1");
writeTrashFile("foo/sext", "2");
writeTrashFile("foo/s.txt", "3");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "foo");
- assertIteration(F, "foo/s.txt", attrs("bar"));
- assertIteration(F, "foo/sext", attrs("bar"));
- assertIteration(D, "sub");
- assertIteration(F, "sub/a.txt");
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "foo");
+ assertIteration(walk, F, "foo/s.txt", attrs("bar"));
+ assertIteration(walk, F, "foo/sext", attrs("bar"));
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/a.txt");
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
public void testPrefixMatchNot() throws Exception {
setupRepo(null, null, "sub/new bar", null);
writeTrashFile("sub/new/foo.txt", "1");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "sub");
- assertIteration(F, "sub/a.txt");
- assertIteration(D, "sub/new", attrs("bar"));
- assertIteration(F, "sub/new/foo.txt");
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/a.txt");
+ assertIteration(walk, D, "sub/new", attrs("bar"));
+ assertIteration(walk, F, "sub/new/foo.txt");
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -385,14 +413,15 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo(null, null, "s[t-v]b/n[de]w bar", null);
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("sub/ndw", "2");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "sub");
- assertIteration(F, "sub/a.txt");
- assertIteration(F, "sub/ndw", attrs("bar"));
- assertIteration(D, "sub/new", attrs("bar"));
- assertIteration(F, "sub/new/foo.txt");
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/a.txt");
+ assertIteration(walk, F, "sub/ndw", attrs("bar"));
+ assertIteration(walk, D, "sub/new", attrs("bar"));
+ assertIteration(walk, F, "sub/new/foo.txt");
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -400,15 +429,16 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo(null, null, "sub/new/* bar", null);
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("sub/new/lower/foo.txt", "2");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "sub");
- assertIteration(F, "sub/a.txt");
- assertIteration(D, "sub/new");
- assertIteration(F, "sub/new/foo.txt", attrs("bar"));
- assertIteration(D, "sub/new/lower", attrs("bar"));
- assertIteration(F, "sub/new/lower/foo.txt");
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/a.txt");
+ assertIteration(walk, D, "sub/new");
+ assertIteration(walk, F, "sub/new/foo.txt", attrs("bar"));
+ assertIteration(walk, D, "sub/new/lower", attrs("bar"));
+ assertIteration(walk, F, "sub/new/lower/foo.txt");
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -417,20 +447,21 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("foo/sub/new/foo.txt", "2");
writeTrashFile("sub/sub/new/foo.txt", "3");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "foo");
- assertIteration(D, "foo/sub");
- assertIteration(D, "foo/sub/new");
- assertIteration(F, "foo/sub/new/foo.txt");
- assertIteration(D, "sub");
- assertIteration(F, "sub/a.txt");
- assertIteration(D, "sub/new", attrs("bar"));
- assertIteration(F, "sub/new/foo.txt");
- assertIteration(D, "sub/sub");
- assertIteration(D, "sub/sub/new");
- assertIteration(F, "sub/sub/new/foo.txt");
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "foo");
+ assertIteration(walk, D, "foo/sub");
+ assertIteration(walk, D, "foo/sub/new");
+ assertIteration(walk, F, "foo/sub/new/foo.txt");
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/a.txt");
+ assertIteration(walk, D, "sub/new", attrs("bar"));
+ assertIteration(walk, F, "sub/new/foo.txt");
+ assertIteration(walk, D, "sub/sub");
+ assertIteration(walk, D, "sub/sub/new");
+ assertIteration(walk, F, "sub/sub/new/foo.txt");
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -438,17 +469,18 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo(null, null, "**/sub/new/ bar", null);
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("foo/sub/new/foo.txt", "2");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "foo");
- assertIteration(D, "foo/sub");
- assertIteration(D, "foo/sub/new", attrs("bar"));
- assertIteration(F, "foo/sub/new/foo.txt");
- assertIteration(D, "sub");
- assertIteration(F, "sub/a.txt");
- assertIteration(D, "sub/new", attrs("bar"));
- assertIteration(F, "sub/new/foo.txt");
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "foo");
+ assertIteration(walk, D, "foo/sub");
+ assertIteration(walk, D, "foo/sub/new", attrs("bar"));
+ assertIteration(walk, F, "foo/sub/new/foo.txt");
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/a.txt");
+ assertIteration(walk, D, "sub/new", attrs("bar"));
+ assertIteration(walk, F, "sub/new/foo.txt");
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -457,20 +489,21 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("foo/sub/new/foo.txt", "2");
writeTrashFile("sub/sub/new/foo.txt", "3");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "foo");
- assertIteration(D, "foo/sub");
- assertIteration(D, "foo/sub/new", attrs("bar"));
- assertIteration(F, "foo/sub/new/foo.txt");
- assertIteration(D, "sub");
- assertIteration(F, "sub/a.txt");
- assertIteration(D, "sub/new", attrs("bar"));
- assertIteration(F, "sub/new/foo.txt");
- assertIteration(D, "sub/sub");
- assertIteration(D, "sub/sub/new", attrs("bar"));
- assertIteration(F, "sub/sub/new/foo.txt");
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "foo");
+ assertIteration(walk, D, "foo/sub");
+ assertIteration(walk, D, "foo/sub/new", attrs("bar"));
+ assertIteration(walk, F, "foo/sub/new/foo.txt");
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/a.txt");
+ assertIteration(walk, D, "sub/new", attrs("bar"));
+ assertIteration(walk, F, "sub/new/foo.txt");
+ assertIteration(walk, D, "sub/sub");
+ assertIteration(walk, D, "sub/sub/new", attrs("bar"));
+ assertIteration(walk, F, "sub/sub/new/foo.txt");
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -479,20 +512,21 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("foo/sub/new/foo.txt", "2");
writeTrashFile("sub/sub/new/foo.txt", "3");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "foo");
- assertIteration(D, "foo/sub");
- assertIteration(D, "foo/sub/new", attrs("bar"));
- assertIteration(F, "foo/sub/new/foo.txt");
- assertIteration(D, "sub");
- assertIteration(F, "sub/a.txt");
- assertIteration(D, "sub/new", attrs("bar"));
- assertIteration(F, "sub/new/foo.txt");
- assertIteration(D, "sub/sub");
- assertIteration(D, "sub/sub/new", attrs("bar"));
- assertIteration(F, "sub/sub/new/foo.txt");
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "foo");
+ assertIteration(walk, D, "foo/sub");
+ assertIteration(walk, D, "foo/sub/new", attrs("bar"));
+ assertIteration(walk, F, "foo/sub/new/foo.txt");
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/a.txt");
+ assertIteration(walk, D, "sub/new", attrs("bar"));
+ assertIteration(walk, F, "sub/new/foo.txt");
+ assertIteration(walk, D, "sub/sub");
+ assertIteration(walk, D, "sub/sub/new", attrs("bar"));
+ assertIteration(walk, F, "sub/sub/new/foo.txt");
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -500,17 +534,18 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo(null, null, "s[uv]b/n*/ bar", null);
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("foo/sub/new/foo.txt", "2");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "foo");
- assertIteration(D, "foo/sub");
- assertIteration(D, "foo/sub/new");
- assertIteration(F, "foo/sub/new/foo.txt");
- assertIteration(D, "sub");
- assertIteration(F, "sub/a.txt");
- assertIteration(D, "sub/new", attrs("bar"));
- assertIteration(F, "sub/new/foo.txt");
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "foo");
+ assertIteration(walk, D, "foo/sub");
+ assertIteration(walk, D, "foo/sub/new");
+ assertIteration(walk, F, "foo/sub/new/foo.txt");
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/a.txt");
+ assertIteration(walk, D, "sub/new", attrs("bar"));
+ assertIteration(walk, F, "sub/new/foo.txt");
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -519,30 +554,32 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("foo/sub/new/foo.txt", "2");
writeTrashFile("foo/new", "3");
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(D, "foo");
- assertIteration(F, "foo/new");
- assertIteration(D, "foo/sub");
- assertIteration(D, "foo/sub/new", attrs("bar"));
- assertIteration(F, "foo/sub/new/foo.txt");
- assertIteration(D, "sub");
- assertIteration(F, "sub/a.txt");
- assertIteration(D, "sub/new", attrs("bar"));
- assertIteration(F, "sub/new/foo.txt");
- endWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, D, "foo");
+ assertIteration(walk, F, "foo/new");
+ assertIteration(walk, D, "foo/sub");
+ assertIteration(walk, D, "foo/sub/new", attrs("bar"));
+ assertIteration(walk, F, "foo/sub/new/foo.txt");
+ assertIteration(walk, D, "sub");
+ assertIteration(walk, F, "sub/a.txt");
+ assertIteration(walk, D, "sub/new", attrs("bar"));
+ assertIteration(walk, F, "sub/new/foo.txt");
+ assertFalse("Not all files tested", walk.next());
+ }
}
private static Collection<Attribute> attrs(String s) {
return new AttributesRule("*", s).getAttributes();
}
- private void assertIteration(FileMode type, String pathName)
+ private void assertIteration(TreeWalk walk, FileMode type, String pathName)
throws IOException {
- assertIteration(type, pathName, Collections.<Attribute> emptyList());
+ assertIteration(walk, type, pathName,
+ Collections.<Attribute> emptyList());
}
- private void assertIteration(FileMode type, String pathName,
+ private void assertIteration(TreeWalk walk, FileMode type, String pathName,
Collection<Attribute> expectedAttrs) throws IOException {
assertTrue("walk has entry", walk.next());
assertEquals(pathName, walk.getPathString());
@@ -611,8 +648,4 @@ public class AttributesHandlerTest extends RepositoryTestCase {
newWalk.addTree(new FileTreeIterator(db));
return newWalk;
}
-
- private void endWalk() throws IOException {
- assertFalse("Not all files tested", walk.next());
- }
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeDirCacheIteratorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeDirCacheIteratorTest.java
index 837de74818..cb37d8978a 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeDirCacheIteratorTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeDirCacheIteratorTest.java
@@ -78,8 +78,6 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
private Git git;
- private TreeWalk walk;
-
@Override
@Before
public void setUp() throws Exception {
@@ -105,23 +103,25 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
// Adds file to index
git.add().addFilepattern(".").call();
- walk = beginWalk();
-
- assertIteration(F, ".gitattributes");
- assertIteration(F, "readme.txt", asList(EOL_LF));
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, F, "readme.txt", asList(EOL_LF));
- assertIteration(D, "src");
+ assertIteration(walk, D, "src");
- assertIteration(D, "src/config");
- assertIteration(F, "src/config/.gitattributes");
- assertIteration(F, "src/config/readme.txt", asList(DELTA_UNSET));
- assertIteration(F, "src/config/windows.file", null);
- assertIteration(F, "src/config/windows.txt", asList(DELTA_UNSET));
+ assertIteration(walk, D, "src/config");
+ assertIteration(walk, F, "src/config/.gitattributes");
+ assertIteration(walk, F, "src/config/readme.txt",
+ asList(DELTA_UNSET));
+ assertIteration(walk, F, "src/config/windows.file", null);
+ assertIteration(walk, F, "src/config/windows.txt",
+ asList(DELTA_UNSET));
- assertIteration(F, "windows.file", null);
- assertIteration(F, "windows.txt", asList(EOL_LF));
+ assertIteration(walk, F, "windows.file", null);
+ assertIteration(walk, F, "windows.txt", asList(EOL_LF));
- endWalk();
+ assertFalse("Not all files tested", walk.next());
+ }
}
/**
@@ -138,17 +138,18 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
// Adds file to index
git.add().addFilepattern(".").call();
- walk = beginWalk();
- assertIteration(F, "l0.txt");
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, "l0.txt");
- assertIteration(D, "level1");
- assertIteration(F, "level1/l1.txt");
+ assertIteration(walk, D, "level1");
+ assertIteration(walk, F, "level1/l1.txt");
- assertIteration(D, "level1/level2");
- assertIteration(F, "level1/level2/l2.txt");
+ assertIteration(walk, D, "level1/level2");
+ assertIteration(walk, F, "level1/level2/l2.txt");
- endWalk();
+ assertFalse("Not all files tested", walk.next());
+ }
}
/**
@@ -166,18 +167,19 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
// Adds file to index
git.add().addFilepattern(".").call();
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
- assertIteration(F, "l0.txt");
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, F, "l0.txt");
- assertIteration(D, "level1");
- assertIteration(F, "level1/l1.txt");
+ assertIteration(walk, D, "level1");
+ assertIteration(walk, F, "level1/l1.txt");
- assertIteration(D, "level1/level2");
- assertIteration(F, "level1/level2/l2.txt");
+ assertIteration(walk, D, "level1/level2");
+ assertIteration(walk, F, "level1/level2/l2.txt");
- endWalk();
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -191,18 +193,19 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
// Adds file to index
git.add().addFilepattern(".").call();
- walk = beginWalk();
- assertIteration(F, ".gitattributes");
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
- assertIteration(D, "levelA");
- assertIteration(F, "levelA/.gitattributes");
- assertIteration(F, "levelA/lA.txt");
+ assertIteration(walk, D, "levelA");
+ assertIteration(walk, F, "levelA/.gitattributes");
+ assertIteration(walk, F, "levelA/lA.txt");
- assertIteration(D, "levelB");
- assertIteration(F, "levelB/.gitattributes");
+ assertIteration(walk, D, "levelB");
+ assertIteration(walk, F, "levelB/.gitattributes");
- endWalk();
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -215,25 +218,27 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
// Adds file to index
git.add().addFilepattern(".").call();
- walk = beginWalk();
- assertIteration(F, "gitattributes");
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, "gitattributes");
- assertIteration(F, "l0.txt");
+ assertIteration(walk, F, "l0.txt");
- assertIteration(D, "levelA");
- assertIteration(F, "levelA/file.gitattributes");
- assertIteration(F, "levelA/lA.txt");
+ assertIteration(walk, D, "levelA");
+ assertIteration(walk, F, "levelA/file.gitattributes");
+ assertIteration(walk, F, "levelA/lA.txt");
- endWalk();
+ assertFalse("Not all files tested", walk.next());
+ }
}
- private void assertIteration(FileMode type, String pathName)
+ private void assertIteration(TreeWalk walk, FileMode type, String pathName)
throws IOException {
- assertIteration(type, pathName, Collections.<Attribute> emptyList());
+ assertIteration(walk, type, pathName,
+ Collections.<Attribute> emptyList());
}
- private void assertIteration(FileMode type, String pathName,
+ private void assertIteration(TreeWalk walk, FileMode type, String pathName,
List<Attribute> nodeAttrs) throws IOException {
assertTrue("walk has entry", walk.next());
assertEquals(pathName, walk.getPathString());
@@ -243,14 +248,14 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
AttributesNode attributesNode = itr.getEntryAttributesNode(db
.newObjectReader());
- assertAttributesNode(pathName, attributesNode, nodeAttrs);
+ assertAttributesNode(walk, pathName, attributesNode, nodeAttrs);
if (D.equals(type))
walk.enterSubtree();
}
- private void assertAttributesNode(String pathName,
+ private void assertAttributesNode(TreeWalk walk, String pathName,
AttributesNode attributesNode, List<Attribute> nodeAttrs)
throws IOException {
if (attributesNode == null)
@@ -292,8 +297,4 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
newWalk.addTree(new DirCacheIterator(db.readDirCache()));
return newWalk;
}
-
- private void endWalk() throws IOException {
- assertFalse("Not all files tested", walk.next());
- }
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeWorkingTreeIteratorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeWorkingTreeIteratorTest.java
index b159cca0d5..9991ae59b0 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeWorkingTreeIteratorTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeWorkingTreeIteratorTest.java
@@ -77,8 +77,6 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
private static Attribute DELTA_UNSET = new Attribute("delta", State.UNSET);
- private TreeWalk walk;
-
@Test
public void testRules() throws Exception {
@@ -102,24 +100,26 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
writeTrashFile("src/config/windows.file", "");
writeTrashFile("src/config/windows.txt", "");
- walk = beginWalk();
-
- assertIteration(F, ".gitattributes");
- assertIteration(F, "global.txt", asList(EOL_LF));
- assertIteration(F, "readme.txt", asList(EOL_LF));
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, F, "global.txt", asList(EOL_LF));
+ assertIteration(walk, F, "readme.txt", asList(EOL_LF));
- assertIteration(D, "src");
+ assertIteration(walk, D, "src");
- assertIteration(D, "src/config");
- assertIteration(F, "src/config/.gitattributes");
- assertIteration(F, "src/config/readme.txt", asList(DELTA_UNSET));
- assertIteration(F, "src/config/windows.file", null);
- assertIteration(F, "src/config/windows.txt", asList(DELTA_UNSET));
+ assertIteration(walk, D, "src/config");
+ assertIteration(walk, F, "src/config/.gitattributes");
+ assertIteration(walk, F, "src/config/readme.txt",
+ asList(DELTA_UNSET));
+ assertIteration(walk, F, "src/config/windows.file", null);
+ assertIteration(walk, F, "src/config/windows.txt",
+ asList(DELTA_UNSET));
- assertIteration(F, "windows.file", null);
- assertIteration(F, "windows.txt", asList(EOL_LF));
+ assertIteration(walk, F, "windows.file", null);
+ assertIteration(walk, F, "windows.txt", asList(EOL_LF));
- endWalk();
+ assertFalse("Not all files tested", walk.next());
+ }
}
/**
@@ -134,17 +134,17 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
writeTrashFile("level1/l1.txt", "");
writeTrashFile("level1/level2/l2.txt", "");
- walk = beginWalk();
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, "l0.txt");
- assertIteration(F, "l0.txt");
+ assertIteration(walk, D, "level1");
+ assertIteration(walk, F, "level1/l1.txt");
- assertIteration(D, "level1");
- assertIteration(F, "level1/l1.txt");
+ assertIteration(walk, D, "level1/level2");
+ assertIteration(walk, F, "level1/level2/l2.txt");
- assertIteration(D, "level1/level2");
- assertIteration(F, "level1/level2/l2.txt");
-
- endWalk();
+ assertFalse("Not all files tested", walk.next());
+ }
}
/**
@@ -160,18 +160,18 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
writeTrashFile("level1/l1.txt", "");
writeTrashFile("level1/level2/l2.txt", "");
- walk = beginWalk();
-
- assertIteration(F, ".gitattributes");
- assertIteration(F, "l0.txt");
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
+ assertIteration(walk, F, "l0.txt");
- assertIteration(D, "level1");
- assertIteration(F, "level1/l1.txt");
+ assertIteration(walk, D, "level1");
+ assertIteration(walk, F, "level1/l1.txt");
- assertIteration(D, "level1/level2");
- assertIteration(F, "level1/level2/l2.txt");
+ assertIteration(walk, D, "level1/level2");
+ assertIteration(walk, F, "level1/level2/l2.txt");
- endWalk();
+ assertFalse("Not all files tested", walk.next());
+ }
}
@Test
@@ -183,26 +183,27 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
writeTrashFile("levelA/lA.txt", "");
- walk = beginWalk();
-
- assertIteration(F, ".gitattributes");
+ try (TreeWalk walk = beginWalk()) {
+ assertIteration(walk, F, ".gitattributes");
- assertIteration(D, "levelA");
- assertIteration(F, "levelA/.gitattributes");
- assertIteration(F, "levelA/lA.txt");
+ assertIteration(walk, D, "levelA");
+ assertIteration(walk, F, "levelA/.gitattributes");
+ assertIteration(walk, F, "levelA/lA.txt");
- assertIteration(D, "levelB");
- assertIteration(F, "levelB/.gitattributes");
+ assertIteration(walk, D, "levelB");
+ assertIteration(walk, F, "levelB/.gitattributes");
- endWalk();
+ assertFalse("Not all files tested", walk.next());
+ }
}
- private void assertIteration(FileMode type, String pathName)
+ private void assertIteration(TreeWalk walk, FileMode type, String pathName)
throws IOException {
- assertIteration(type, pathName, Collections.<Attribute> emptyList());
+ assertIteration(walk, type, pathName,
+ Collections.<Attribute> emptyList());
}
- private void assertIteration(FileMode type, String pathName,
+ private void assertIteration(TreeWalk walk, FileMode type, String pathName,
List<Attribute> nodeAttrs)
throws IOException {
assertTrue("walk has entry", walk.next());
@@ -212,13 +213,13 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
assertNotNull("has tree", itr);
AttributesNode attributesNode = itr.getEntryAttributesNode();
- assertAttributesNode(pathName, attributesNode, nodeAttrs);
+ assertAttributesNode(walk, pathName, attributesNode, nodeAttrs);
if (D.equals(type))
walk.enterSubtree();
}
- private void assertAttributesNode(String pathName,
+ private void assertAttributesNode(TreeWalk walk, String pathName,
AttributesNode attributesNode, List<Attribute> nodeAttrs)
throws IOException {
if (attributesNode == null)
@@ -259,8 +260,4 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
newWalk.addTree(new FileTreeIterator(db));
return newWalk;
}
-
- private void endWalk() throws IOException {
- assertFalse("Not all files tested", walk.next());
- }
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java
index d6aead4a52..0291fcc1e9 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java
@@ -131,6 +131,12 @@ public class TreeWalkAttributeTest extends RepositoryTestCase {
@Override
@After
public void tearDown() throws Exception {
+ if (walk != null) {
+ walk.close();
+ }
+ if (ci_walk != null) {
+ ci_walk.close();
+ }
super.tearDown();
if (customAttributeFile != null)
customAttributeFile.delete();