From f7707e402aade0f96576b9ab648382af5ba56c4b Mon Sep 17 00:00:00 2001 From: Fabio Ponciroli Date: Wed, 2 Feb 2022 20:05:55 +0100 Subject: [PATCH] Make sure to close Repository in tests Repository wasn't closed in FetchAndPullCommandsRecurseSubmodulesTest. This caused a "Resource leak: 'g' is never closed" warning during compilation. Bug: 578546 Change-Id: I591ef1e286bcd9a7103c016fd47015e77fa95cbb --- .../jgit/api/FetchAndPullCommandsRecurseSubmodulesTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 82624abb1d..9ea64efc64 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 @@ -259,8 +259,8 @@ public class FetchAndPullCommandsRecurseSubmodulesTest extends RepositoryTestCas // the commit that was created try (SubmoduleWalk w = SubmoduleWalk.forIndex(git.getRepository())) { assertTrue(w.next()); - try (Repository repository = w.getRepository()) { - Git g = new Git(repository); + try (Repository repository = w.getRepository(); + Git g = new Git(repository)) { g.fetch().setRemote(REMOTE).setRefSpecs(REFSPEC).call(); g.reset().setMode(ResetType.HARD).setRef(commit1.name()).call(); } -- 2.39.5