another fix for the concurrentModificationException in AccessTracker

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3944 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 84be912e90
commit 28baecd41b

@ -45,6 +45,14 @@ import de.anomic.yacy.yacySeed;
public class AccessTracker_p {
private static final TreeMap treemapclone(TreeMap m) {
TreeMap accessClone = new TreeMap();
try {
accessClone.putAll(m);
} catch (ConcurrentModificationException e) {}
return accessClone;
}
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch sb) {
plasmaSwitchboard switchboard = (plasmaSwitchboard) sb;
@ -85,7 +93,7 @@ public class AccessTracker_p {
access = switchboard.accessTrack(host);
if (access != null) {
try {
Iterator ii = access.entrySet().iterator();
Iterator ii = treemapclone(access).entrySet().iterator();
while (ii.hasNext()) {
entry = (Map.Entry) ii.next();
prop.put("page_list_" + entCount + "_host", host);
@ -101,7 +109,7 @@ public class AccessTracker_p {
while ((entCount < maxCount) && (i.hasNext())) {
host = (String) i.next();
access = switchboard.accessTrack(host);
Iterator ii = access.entrySet().iterator();
Iterator ii = treemapclone(access).entrySet().iterator();
while (ii.hasNext()) {
entry = (Map.Entry) ii.next();
prop.put("page_list_" + entCount + "_host", host);

@ -208,7 +208,11 @@ public abstract class serverAbstractSwitch implements serverSwitch {
public Iterator accessHosts() {
// returns an iterator of hosts in tracker (String)
return accessTracker.keySet().iterator();
HashMap accessTrackerClone = new HashMap();
try {
accessTrackerClone.putAll(accessTracker);
} catch (ConcurrentModificationException e) {}
return accessTrackerClone.keySet().iterator();
}
public void setConfig(Map otherConfigs) {

Loading…
Cancel
Save