Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

fix for a ConcurrentModificationException

orbiter20c5d78a5c3e
diff --git a/source/de/anomic/search/RankingProcess.java b/source/de/anomic/search/RankingProcess.java
index 0f813ce29..69659d163 100644
--- a/source/de/anomic/search/RankingProcess.java
+++ b/source/de/anomic/search/RankingProcess.java
@@ -31,6 +31,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.ConcurrentModificationException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -335,20 +336,27 @@ public final class RankingProcess extends Thread {
}
// no more entries in sorted RWI entries. Now take Elements from the doubleDomCache
// find best entry from all caches
- final Iterator<SortStack<WordReferenceVars>> i = this.doubleDomCache.values().iterator();
SortStack<WordReferenceVars>.stackElement bestEntry = null;
SortStack<WordReferenceVars>.stackElement o;
- while (i.hasNext()) {
- m = i.next();
- if (m == null) continue;
- if (m.size() == 0) continue;
- if (bestEntry == null) {
- bestEntry = m.top();
- continue;
- }
- o = m.top();
- if (o.weight.longValue() < bestEntry.weight.longValue()) {
- bestEntry = o;
+ synchronized (this.doubleDomCache) {
+ final Iterator<SortStack<WordReferenceVars>> i = this.doubleDomCache.values().iterator();
+ while (i.hasNext()) {
+ try {
+ m = i.next();
+ } catch (ConcurrentModificationException e) {
+ Log.logException(e);
+ break; // not the best solution...
+ }
+ if (m == null) continue;
+ if (m.size() == 0) continue;
+ if (bestEntry == null) {
+ bestEntry = m.top();
+ continue;
+ }
+ o = m.top();
+ if (o.weight.longValue() < bestEntry.weight.longValue()) {
+ bestEntry = o;
+ }
}
}
if (bestEntry == null) return null;