Browse Source

RepositoryCache: simplify code

The type parameters can now be inferred when creating
ConcurrentHashMap.

A for loop over the keys of a ConcurrentHashMap doesn't
need to use an Iterator<Map.Entry>; loop syntax handles
this just fine over keySet().

Change-Id: I1f85bb81b77f7cd1caec77197f2f0bf78e4a82a1
stable-4.6
Shawn Pearce 8 years ago committed by David Pursehouse
parent
commit
3b2248c5cf
  1. 9
      org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java

9
org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java

@ -47,8 +47,6 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
@ -225,7 +223,7 @@ public class RepositoryCache {
private volatile long expireAfter;
private RepositoryCache() {
cacheMap = new ConcurrentHashMap<Key, Repository>();
cacheMap = new ConcurrentHashMap<>();
openLocks = new Lock[4];
for (int i = 0; i < openLocks.length; i++) {
openLocks[i] = new Lock();
@ -314,9 +312,8 @@ public class RepositoryCache {
}
private void clearAll() {
for (Iterator<Map.Entry<Key, Repository>> i = cacheMap
.entrySet().iterator(); i.hasNext();) {
unregisterAndCloseRepository(i.next().getKey());
for (Key k : cacheMap.keySet()) {
unregisterAndCloseRepository(k);
}
}

Loading…
Cancel
Save