From: Fabio Ponciroli Date: Wed, 2 Feb 2022 19:05:55 +0000 (+0100) Subject: Make sure to close Repository in tests X-Git-Tag: v6.1.0.202202221755-m3~18 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fchanges%2F34%2F190334%2F4;p=jgit.git 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 --- 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(); }