]> source.dussan.org Git - jgit.git/commitdiff
GitConstructionTest: Open Git instance in try-with-resource 87/66587/1
authorDavid Pursehouse <david.pursehouse@sonymobile.com>
Mon, 15 Feb 2016 08:07:22 +0000 (17:07 +0900)
committerDavid Pursehouse <david.pursehouse@sonymobile.com>
Mon, 15 Feb 2016 08:07:22 +0000 (17:07 +0900)
Change-Id: Iddf658acd1c78161d6028cfcfb7e5c73534ae40b
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java

index 2220a536f147628df58ea9b77423f2a0e8cc9127..3bff8f2ff6630c10513f7d02c24b9cd5ea417d9e 100644 (file)
@@ -66,11 +66,12 @@ public class GitConstructionTest extends RepositoryTestCase {
        @Before
        public void setUp() throws Exception {
                super.setUp();
-               Git git = new Git(db);
-               git.commit().setMessage("initial commit").call();
-               writeTrashFile("Test.txt", "Hello world");
-               git.add().addFilepattern("Test.txt").call();
-               git.commit().setMessage("Initial commit").call();
+               try (Git git = new Git(db)) {
+                       git.commit().setMessage("initial commit").call();
+                       writeTrashFile("Test.txt", "Hello world");
+                       git.add().addFilepattern("Test.txt").call();
+                       git.commit().setMessage("Initial commit").call();
+               }
 
                bareRepo = Git.cloneRepository().setBare(true)
                                .setURI(db.getDirectory().toURI().toString())