]> source.dussan.org Git - jgit.git/commitdiff
RefUpdateTest: Don't call createBareRepository in try-with-resource 23/89723/2
authorDavid Pursehouse <david.pursehouse@gmail.com>
Fri, 27 Jan 2017 10:33:20 +0000 (19:33 +0900)
committerMatthias Sohn <matthias.sohn@sap.com>
Sat, 28 Jan 2017 18:16:48 +0000 (19:16 +0100)
createBareRepository adds the created repo to the list of repos to be
closed in the superclass's teardown. Wrapping it in try-with-resource
causes it to be closed too many times, resulting in a corrupt use
count.

Change-Id: I4c70630bf6008544324dda453deb141f4f89472c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java

index 4be1d6d370941174e1c7b6d7b4023029b029271c..daef91d53cbff1368f9bf82883493388aa3890bb 100644 (file)
@@ -239,14 +239,14 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase {
 
        @Test
        public void testDeleteHeadInBareRepo() throws IOException {
-               try (Repository bareRepo = createBareRepository()) {
-                       RefUpdate ref = bareRepo.updateRef(Constants.HEAD);
-                       ref.setNewObjectId(ObjectId.fromString("0123456789012345678901234567890123456789"));
-                       // Create the HEAD ref so we can delete it.
-                       assertEquals(Result.NEW, ref.update());
-                       ref = bareRepo.updateRef(Constants.HEAD);
-                       delete(bareRepo, ref, Result.NO_CHANGE, true, true);
-               }
+               Repository bareRepo = createBareRepository();
+               RefUpdate ref = bareRepo.updateRef(Constants.HEAD);
+               ref.setNewObjectId(ObjectId
+                               .fromString("0123456789012345678901234567890123456789"));
+               // Create the HEAD ref so we can delete it.
+               assertEquals(Result.NEW, ref.update());
+               ref = bareRepo.updateRef(Constants.HEAD);
+               delete(bareRepo, ref, Result.NO_CHANGE, true, true);
        }
        /**
         * Delete a loose ref and make sure the directory in refs is deleted too,