diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2019-01-20 19:58:10 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2019-01-20 20:09:16 +0900 |
commit | 52923e9b077147d6734699f78247ac5b7666332f (patch) | |
tree | 0567accdd2ddc2f385ceedfaf6b8ebb34c15761c /org.eclipse.jgit.test/tst | |
parent | 91b1fe4687c3bff3195e6f2ff207ea96fa626cca (diff) | |
download | jgit-52923e9b077147d6734699f78247ac5b7666332f.tar.gz jgit-52923e9b077147d6734699f78247ac5b7666332f.zip |
LocalDiskRepositoryTestCase#createRepository: Default auto-close to false
Since 8ed59c5 ("Make TestRepository AutoCloseable", Jan 11, 2019) the
TestRepository class is auto-closeable, but instantiations of it were
not converted to use try-with-resource.
Converting to try-with-resource results, in several cases, in the
repository being closed twice because LocalDiskRepositoryTestCase has
logic to close created repositories in the tearDown method. This results
in several tests emitting a warning to the console:
close() called when useCnt is already zero
Change the default behavior of the createRepository method to not use
the auto-close logic in LocalDiskRepositoryTestCase, so that thy will
instead be closed (only once) using the AutoCloseable implementation.
Deprecate the method that has the autoClose parameter.
Change-Id: I63d62c9913f9b61271667861dae144e551d358c1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java index 58b005c282..15c4e4a029 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java @@ -110,7 +110,7 @@ public class RepositoryCacheTest extends RepositoryTestCase { @Test public void testFileKeyOpenNew() throws IOException { File gitdir; - try (Repository n = createRepository(true, false)) { + try (Repository n = createRepository(true)) { gitdir = n.getDirectory(); } recursiveDelete(gitdir); @@ -192,7 +192,7 @@ public class RepositoryCacheTest extends RepositoryTestCase { @Test public void testRepositoryUsageCountWithRegisteredRepository() throws IOException { - @SuppressWarnings("resource") // We are testing the close() method + @SuppressWarnings({"resource", "deprecation"}) // We are testing the close() method Repository repo = createRepository(false, false); assertEquals(1, repo.useCnt.get()); RepositoryCache.register(repo); @@ -240,9 +240,9 @@ public class RepositoryCacheTest extends RepositoryTestCase { @Test public void testRepositoryUnregisteringWhenExpired() throws Exception { - @SuppressWarnings("resource") // We are testing the close() method + @SuppressWarnings({"resource", "deprecation"}) // We are testing the close() method Repository repoA = createRepository(true, false); - @SuppressWarnings("resource") // We are testing the close() method + @SuppressWarnings({"resource", "deprecation"}) // We are testing the close() method Repository repoB = createRepository(true, false); Repository repoC = createBareRepository(); RepositoryCache.register(repoA); @@ -276,7 +276,7 @@ public class RepositoryCacheTest extends RepositoryTestCase { @Test public void testReconfigure() throws InterruptedException, IOException { - @SuppressWarnings("resource") // We are testing the close() method + @SuppressWarnings({"resource", "deprecation"}) // We are testing the close() method Repository repo = createRepository(false, false); RepositoryCache.register(repo); assertTrue(RepositoryCache.isCached(repo)); |