diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2016-10-14 00:04:05 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2016-10-14 00:24:00 +0200 |
commit | ba7ba7a816ad7e936f413a3c7686deb790cce525 (patch) | |
tree | c06722eeb8e4dba541d58ecfbfe549dfa223c6a7 /org.eclipse.jgit.test | |
parent | b8e3e194e3200adfb0c64a4d79b9bfbb0837b00c (diff) | |
parent | 535f0afd13b3df42be5cfc9e93fddcbb223aa2f6 (diff) | |
download | jgit-ba7ba7a816ad7e936f413a3c7686deb790cce525.tar.gz jgit-ba7ba7a816ad7e936f413a3c7686deb790cce525.zip |
Merge branch 'stable-4.5'
* stable-4.5:
Unconditionally close repositories in RepositoryCache.clear()
Fix eviction of repositories with negative usage count
Adapt to parameter removed from
RepositoryCache.unregisterAndCloseRepository().
Change-Id: I7087667056ced401a3b3a027977f2715cd77a1c5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java | 21 |
1 files changed, 21 insertions, 0 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 6bea320120..b44b4c34a7 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 @@ -210,6 +210,27 @@ public class RepositoryCacheTest extends RepositoryTestCase { } @Test + public void testRepositoryUnregisteringWhenExpiredAndUsageCountNegative() + throws Exception { + Repository repoA = createBareRepository(); + RepositoryCache.register(repoA); + + assertEquals(1, RepositoryCache.getRegisteredKeys().size()); + assertTrue(RepositoryCache.isCached(repoA)); + + // close the repo twice to make usage count negative + repoA.close(); + repoA.close(); + // fake that repoA was closed more than 1 hour ago (default expiration + // time) + repoA.closedAt.set(System.currentTimeMillis() - 65 * 60 * 1000); + + RepositoryCache.clearExpired(); + + assertEquals(0, RepositoryCache.getRegisteredKeys().size()); + } + + @Test public void testRepositoryUnregisteringWhenExpired() throws Exception { Repository repoA = createBareRepository(); Repository repoB = createBareRepository(); |