From 20c5d78a5c3ef1ee80cff6a78046eb77a5fd21c1 Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 11 Nov 2009 23:31:12 +0000 Subject: [PATCH] fix for a ConcurrentModificationException git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6478 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/search/RankingProcess.java | 32 +++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) 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> i = this.doubleDomCache.values().iterator(); SortStack.stackElement bestEntry = null; SortStack.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> 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;