Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2016-02-15 03:16:00 -0500
committerDavid Pursehouse2016-02-15 03:16:00 -0500
commit0973c9fc488f99185e152179ba46d49957fff078 (patch)
tree40a23b553ddc6677361a2ea09bf2e2be7a890fec
parent259dca06ec5b3371106f0981c21ae63b95fbcff2 (diff)
downloadjgit-0973c9fc488f99185e152179ba46d49957fff078.tar.gz
jgit-0973c9fc488f99185e152179ba46d49957fff078.tar.xz
jgit-0973c9fc488f99185e152179ba46d49957fff078.zip
DirCacheCGitCompatabilityTest: Open TreeWalk in try-with-resource
Change-Id: I81a8bd2aba7eb0a6efaea5d6f7720aa725052157 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java
index 7f58a1cbed..3e780467bf 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java
@@ -98,17 +98,18 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase {
assertEquals(ls.size(), dc.getEntryCount());
{
final Iterator<CGitIndexRecord> rItr = ls.values().iterator();
- final TreeWalk tw = new TreeWalk(db);
- tw.setRecursive(true);
- tw.addTree(new DirCacheIterator(dc));
- while (rItr.hasNext()) {
- final DirCacheIterator dcItr;
-
- assertTrue(tw.next());
- dcItr = tw.getTree(0, DirCacheIterator.class);
- assertNotNull(dcItr);
-
- assertEqual(rItr.next(), dcItr.getDirCacheEntry());
+ try (final TreeWalk tw = new TreeWalk(db)) {
+ tw.setRecursive(true);
+ tw.addTree(new DirCacheIterator(dc));
+ while (rItr.hasNext()) {
+ final DirCacheIterator dcItr;
+
+ assertTrue(tw.next());
+ dcItr = tw.getTree(0, DirCacheIterator.class);
+ assertNotNull(dcItr);
+
+ assertEqual(rItr.next(), dcItr.getDirCacheEntry());
+ }
}
}
}

Back to the top