summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2016-02-15 17:17:17 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2016-02-15 17:17:17 +0900
commitfc4ac28aa9749e277ece1f628b64900c10b85d5c (patch)
tree660c85a53cec5b3a854db9ea5e06bf06f6cd425c
parent0973c9fc488f99185e152179ba46d49957fff078 (diff)
downloadjgit-fc4ac28aa9749e277ece1f628b64900c10b85d5c.tar.gz
jgit-fc4ac28aa9749e277ece1f628b64900c10b85d5c.zip
DirCacheBuilderIteratorTest: Open TreeWalk in try-with-resource
Change-Id: I94836315918924cba9a2b5be6b9ae417cb2ad215 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderIteratorTest.java31
1 files changed, 16 insertions, 15 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderIteratorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderIteratorTest.java
index 8561fdf35b..2b108870f9 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderIteratorTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderIteratorTest.java
@@ -78,23 +78,24 @@ public class DirCacheBuilderIteratorTest extends RepositoryTestCase {
final int expIdx = 2;
final DirCacheBuilder b = dc.builder();
- final TreeWalk tw = new TreeWalk(db);
- tw.addTree(new DirCacheBuildIterator(b));
- tw.setRecursive(true);
- tw.setFilter(PathFilterGroup.createFromStrings(Collections
- .singleton(paths[expIdx])));
+ try (final TreeWalk tw = new TreeWalk(db)) {
+ tw.addTree(new DirCacheBuildIterator(b));
+ tw.setRecursive(true);
+ tw.setFilter(PathFilterGroup.createFromStrings(Collections
+ .singleton(paths[expIdx])));
- assertTrue("found " + paths[expIdx], tw.next());
- final DirCacheIterator c = tw.getTree(0, DirCacheIterator.class);
- assertNotNull(c);
- assertEquals(expIdx, c.ptr);
- assertSame(ents[expIdx], c.getDirCacheEntry());
- assertEquals(paths[expIdx], tw.getPathString());
- assertEquals(mode.getBits(), tw.getRawMode(0));
- assertSame(mode, tw.getFileMode(0));
- b.add(c.getDirCacheEntry());
+ assertTrue("found " + paths[expIdx], tw.next());
+ final DirCacheIterator c = tw.getTree(0, DirCacheIterator.class);
+ assertNotNull(c);
+ assertEquals(expIdx, c.ptr);
+ assertSame(ents[expIdx], c.getDirCacheEntry());
+ assertEquals(paths[expIdx], tw.getPathString());
+ assertEquals(mode.getBits(), tw.getRawMode(0));
+ assertSame(mode, tw.getFileMode(0));
+ b.add(c.getDirCacheEntry());
- assertFalse("no more entries", tw.next());
+ assertFalse("no more entries", tw.next());
+ }
b.finish();
assertEquals(ents.length, dc.getEntryCount());