Skip to content

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

fix for ConcurrentModificationException at de.anomic.index.indexContainerHeap$heapCacheIterator.next(indexContainerHeap.java:324)

danielr0f9c0bd0d52e
diff --git a/source/de/anomic/index/indexContainerHeap.java b/source/de/anomic/index/indexContainerHeap.java
index 2d7ba8f1f..07d24aad0 100755
--- a/source/de/anomic/index/indexContainerHeap.java
+++ b/source/de/anomic/index/indexContainerHeap.java
@@ -314,25 +314,29 @@ public final class indexContainerHeap {
return new heapCacheIterator((String) secondWordHash, rot);
}
- public boolean hasNext() {
+ public synchronized boolean hasNext() {
if (rot) return true;
return iterator.hasNext();
}
- public indexContainer next() {
- if (iterator.hasNext()) {
+ public synchronized indexContainer next() {
+ synchronized(iterator) {
+ if (iterator.hasNext()) {
+ return (iterator.next()).topLevelClone();
+ }
+ // rotation iteration
+ if (!rot) {
+ return null;
+ }
+ iterator = cache.values().iterator();
return (iterator.next()).topLevelClone();
}
- // rotation iteration
- if (!rot) {
- return null;
- }
- iterator = cache.values().iterator();
- return (iterator.next()).topLevelClone();
}
- public void remove() {
- iterator.remove();
+ public synchronized void remove() {
+ synchronized(iterator) {
+ iterator.remove();
+ }
}
public Iterator<indexContainer> iterator() {