]> source.dussan.org Git - jgit.git/commitdiff
CloneCommandTest: Open Repository in try-with-resource 24/118724/1
authorDavid Pursehouse <david.pursehouse@gmail.com>
Mon, 5 Mar 2018 23:20:45 +0000 (08:20 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Mon, 5 Mar 2018 23:20:45 +0000 (08:20 +0900)
Change-Id: Id09d2126fb17d84581f8637e83a75dfa2e85ebe8
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java

index e687a6ca7f767b4c6816478c800f1d5f911dece2..0d7009dca4b59357d99d5c469cd4f50c5891736d 100644 (file)
@@ -601,17 +601,17 @@ public class CloneCommandTest extends RepositoryTestCase {
 
                SubmoduleWalk walk = SubmoduleWalk.forIndex(git2.getRepository());
                assertTrue(walk.next());
-               Repository clonedSub1 = walk.getRepository();
-               assertNotNull(clonedSub1);
-               assertEquals(
-                               new File(git2.getRepository().getWorkTree(), walk.getPath()),
-                               clonedSub1.getWorkTree());
-               assertEquals(new File(new File(git2.getRepository().getDirectory(),
-                               "modules"), walk.getPath()),
-                               clonedSub1.getDirectory());
-               status = new SubmoduleStatusCommand(clonedSub1);
-               statuses = status.call();
-               clonedSub1.close();
+               try (Repository clonedSub1 = walk.getRepository()) {
+                       assertNotNull(clonedSub1);
+                       assertEquals(new File(git2.getRepository().getWorkTree(),
+                                       walk.getPath()), clonedSub1.getWorkTree());
+                       assertEquals(
+                                       new File(new File(git2.getRepository().getDirectory(),
+                                                       "modules"), walk.getPath()),
+                                       clonedSub1.getDirectory());
+                       status = new SubmoduleStatusCommand(clonedSub1);
+                       statuses = status.call();
+               }
                pathStatus = statuses.get(path);
                assertNotNull(pathStatus);
                assertEquals(SubmoduleStatusType.INITIALIZED, pathStatus.getType());