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 | |
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')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java index e5a0553ab4..9a57349f56 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java @@ -298,7 +298,7 @@ public class RepositoryCache { } private boolean isExpired(Repository db) { - return db != null && db.useCnt.get() == 0 + return db != null && db.useCnt.get() <= 0 && (System.currentTimeMillis() - db.closedAt.get() > expireAfter); } @@ -325,15 +325,9 @@ public class RepositoryCache { } private void clearAll() { - for (int stage = 0; stage < 2; stage++) { - for (Iterator<Map.Entry<Key, Reference<Repository>>> i = cacheMap - .entrySet().iterator(); i.hasNext();) { - final Map.Entry<Key, Reference<Repository>> e = i.next(); - final Repository db = e.getValue().get(); - if (db != null) - db.close(); - i.remove(); - } + for (Iterator<Map.Entry<Key, Reference<Repository>>> i = cacheMap + .entrySet().iterator(); i.hasNext();) { + unregisterAndCloseRepository(i.next().getKey()); } } |