diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2017-01-28 21:19:55 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2017-01-28 21:19:55 +0100 |
commit | 53ad4373825f444bc011d046e0acd3dfe5eaeca7 (patch) | |
tree | bef19ac4f7021dbba9a2c83df2dfbe2f6e05979a /org.eclipse.jgit.junit/src/org/eclipse | |
parent | ac6353e9e5fbcf0c1a298990505674077ff09a22 (diff) | |
download | jgit-53ad4373825f444bc011d046e0acd3dfe5eaeca7.tar.gz jgit-53ad4373825f444bc011d046e0acd3dfe5eaeca7.zip |
RepositoryCacheTest: avoid to close already closed repository
The tearDown() of the superclass closed the repository once more which
led to a negative use count warning logged by Repository.close().
Change-Id: I331f85a540c68264a53456276c32f72b79113d61
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit/src/org/eclipse')
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java index 42e201e932..ceb0452350 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java @@ -359,12 +359,32 @@ public abstract class LocalDiskRepositoryTestCase { * @throws IOException * the repository could not be created in the temporary area */ - private FileRepository createRepository(boolean bare) throws IOException { + private FileRepository createRepository(boolean bare) + throws IOException { + return createRepository(bare, true); + } + + /** + * Creates a new empty repository. + * + * @param bare + * true to create a bare repository; false to make a repository + * within its working directory + * @param autoClose + * auto close the repository in #tearDown + * @return the newly created repository, opened for access + * @throws IOException + * the repository could not be created in the temporary area + */ + public FileRepository createRepository(boolean bare, boolean autoClose) + throws IOException { File gitdir = createUniqueTestGitDir(bare); FileRepository db = new FileRepository(gitdir); assertFalse(gitdir.exists()); db.create(bare); - addRepoToClose(db); + if (autoClose) { + addRepoToClose(db); + } return db; } |