From 0973c9fc488f99185e152179ba46d49957fff078 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Mon, 15 Feb 2016 17:16:00 +0900 Subject: [PATCH] DirCacheCGitCompatabilityTest: Open TreeWalk in try-with-resource Change-Id: I81a8bd2aba7eb0a6efaea5d6f7720aa725052157 Signed-off-by: David Pursehouse --- .../DirCacheCGitCompatabilityTest.java | 23 ++++++++++--------- 1 file 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 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()); + } } } } -- 2.39.5