diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2019-10-15 00:58:27 +0200 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2019-10-15 08:54:25 +0200 |
commit | 5e0eca69432c4a382ab6b0d08728f52b1e305a30 (patch) | |
tree | 4e322c03d313c39b7ecc9cd1bded6cadf1013638 /org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchAndPullCommandsRecurseSubmodulesTest.java | |
parent | 36e16435bed5ba457f6d709643acc93505e99d2c (diff) | |
download | jgit-5e0eca69432c4a382ab6b0d08728f52b1e305a30.tar.gz jgit-5e0eca69432c4a382ab6b0d08728f52b1e305a30.zip |
Close SubmoduleWalks in tests
Change-Id: If1b9d80830b6b136d4ab33f5c7043b140bd92f85
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchAndPullCommandsRecurseSubmodulesTest.java')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchAndPullCommandsRecurseSubmodulesTest.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchAndPullCommandsRecurseSubmodulesTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchAndPullCommandsRecurseSubmodulesTest.java index 73a705b252..08ded559f5 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchAndPullCommandsRecurseSubmodulesTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchAndPullCommandsRecurseSubmodulesTest.java @@ -343,19 +343,22 @@ public class FetchAndPullCommandsRecurseSubmodulesTest extends RepositoryTestCas private void assertSubmoduleFetchHeads(ObjectId expectedHead1, ObjectId expectedHead2) throws Exception { + Object newHead1 = null; + ObjectId newHead2 = null; try (SubmoduleWalk walk = SubmoduleWalk .forIndex(git2.getRepository())) { assertTrue(walk.next()); - Repository r = walk.getRepository(); - ObjectId newHead1 = r.resolve(Constants.FETCH_HEAD); - ObjectId newHead2; - try (SubmoduleWalk walk2 = SubmoduleWalk.forIndex(r)) { - assertTrue(walk2.next()); - newHead2 = walk2.getRepository().resolve(Constants.FETCH_HEAD); + try (Repository r = walk.getRepository()) { + newHead1 = r.resolve(Constants.FETCH_HEAD); + try (SubmoduleWalk walk2 = SubmoduleWalk.forIndex(r)) { + assertTrue(walk2.next()); + try (Repository r2 = walk2.getRepository()) { + newHead2 = r2.resolve(Constants.FETCH_HEAD); + } + } } - - assertEquals(expectedHead1, newHead1); - assertEquals(expectedHead2, newHead2); } + assertEquals(expectedHead1, newHead1); + assertEquals(expectedHead2, newHead2); } } |