]> source.dussan.org Git - jgit.git/commitdiff
Make sure to close Repository in tests 34/190334/4
authorFabio Ponciroli <ponch78@gmail.com>
Wed, 2 Feb 2022 19:05:55 +0000 (20:05 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 2 Feb 2022 22:00:27 +0000 (23:00 +0100)
Repository wasn't closed in FetchAndPullCommandsRecurseSubmodulesTest.
This caused a "Resource leak: 'g' is never closed" warning during
compilation.

Bug: 578546
Change-Id: I591ef1e286bcd9a7103c016fd47015e77fa95cbb

org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchAndPullCommandsRecurseSubmodulesTest.java

index 82624abb1db0f6d491ee2b7d27feed6403f583b0..9ea64efc64479533f60857d86dc46b02a6aeff4a 100644 (file)
@@ -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();
                        }