diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2019-10-15 08:52:39 +0200 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2019-10-15 13:24:30 +0200 |
commit | 563ec9ecb671d5b329a71c08ff49e9acd4fa0b33 (patch) | |
tree | 51ea209bbc981adb2364798e6fbec892cc23840c /org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/CherryPickTest.java | |
parent | 5e0eca69432c4a382ab6b0d08728f52b1e305a30 (diff) | |
download | jgit-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/merge/CherryPickTest.java')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/CherryPickTest.java | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/CherryPickTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/CherryPickTest.java index 19f6dcbc59..aa4392fcac 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/CherryPickTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/CherryPickTest.java @@ -106,23 +106,24 @@ public class CherryPickTest extends RepositoryTestCase { boolean merge = twm.merge(new ObjectId[] { O, T }); assertTrue(merge); - final TreeWalk tw = new TreeWalk(db); - tw.setRecursive(true); - tw.reset(twm.getResultTreeId()); + try (TreeWalk tw = new TreeWalk(db)) { + tw.setRecursive(true); + tw.reset(twm.getResultTreeId()); - assertTrue(tw.next()); - assertEquals("a", tw.getPathString()); - assertCorrectId(treeO, tw); + assertTrue(tw.next()); + assertEquals("a", tw.getPathString()); + assertCorrectId(treeO, tw); - assertTrue(tw.next()); - assertEquals("o", tw.getPathString()); - assertCorrectId(treeO, tw); + assertTrue(tw.next()); + assertEquals("o", tw.getPathString()); + assertCorrectId(treeO, tw); - assertTrue(tw.next()); - assertEquals("t", tw.getPathString()); - assertCorrectId(treeT, tw); + assertTrue(tw.next()); + assertEquals("t", tw.getPathString()); + assertCorrectId(treeT, tw); - assertFalse(tw.next()); + assertFalse(tw.next()); + } } @Test @@ -168,19 +169,20 @@ public class CherryPickTest extends RepositoryTestCase { boolean merge = twm.merge(new ObjectId[] { B, T }); assertTrue(merge); - final TreeWalk tw = new TreeWalk(db); - tw.setRecursive(true); - tw.reset(twm.getResultTreeId()); + try (TreeWalk tw = new TreeWalk(db)) { + tw.setRecursive(true); + tw.reset(twm.getResultTreeId()); - assertTrue(tw.next()); - assertEquals("a", tw.getPathString()); - assertCorrectId(treeB, tw); + assertTrue(tw.next()); + assertEquals("a", tw.getPathString()); + assertCorrectId(treeB, tw); - assertTrue(tw.next()); - assertEquals("t", tw.getPathString()); - assertCorrectId(treeT, tw); + assertTrue(tw.next()); + assertEquals("t", tw.getPathString()); + assertCorrectId(treeT, tw); - assertFalse(tw.next()); + assertFalse(tw.next()); + } } private static void assertCorrectId(DirCache treeT, TreeWalk tw) { |