summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2016-10-11 15:28:41 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2016-10-13 23:39:12 +0200
commit535f0afd13b3df42be5cfc9e93fddcbb223aa2f6 (patch)
treef326d3737f57310dd2d353eb8f1f1f7f83b5dd03
parent5a1e147eaa729ba0ba75bdeebcc745a55bff6232 (diff)
downloadjgit-535f0afd13b3df42be5cfc9e93fddcbb223aa2f6.tar.gz
jgit-535f0afd13b3df42be5cfc9e93fddcbb223aa2f6.zip
Unconditionally close repositories in RepositoryCache.clear()
Earlier we tried to close the repository before removing it from the cache, so close only reduced refcount but didn't close it. Now that we no longer leak usage count on purpose and the usage count is now ignored anyway, there is no longer a need to run the removal twice. Change-Id: I8b62cec6d8a3e88c096d1f37a1f7f5a5066c90a0 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java12
1 files changed, 3 insertions, 9 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 98ac601130..7a8d246df2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
@@ -326,15 +326,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(), null);
}
}