aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/java/util/WeakHashMap.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/util/WeakHashMap.java')
-rw-r--r--libjava/classpath/java/util/WeakHashMap.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/libjava/classpath/java/util/WeakHashMap.java b/libjava/classpath/java/util/WeakHashMap.java
index 7593f7e330e..514ad8cd29f 100644
--- a/libjava/classpath/java/util/WeakHashMap.java
+++ b/libjava/classpath/java/util/WeakHashMap.java
@@ -241,7 +241,8 @@ public class WeakHashMap extends AbstractMap implements Map
// This method will get inlined.
cleanQueue();
if (knownMod != modCount)
- throw new ConcurrentModificationException();
+ throw new ConcurrentModificationException(knownMod + " != "
+ + modCount);
}
/**
@@ -698,21 +699,20 @@ public class WeakHashMap extends AbstractMap implements Map
// bucket may be enqueued later by the garbage collection, and
// internalRemove will be called a second time.
bucket.slot = -1;
- if (buckets[slot] == bucket)
- buckets[slot] = bucket.next;
- else
+
+ WeakBucket prev = null;
+ WeakBucket next = buckets[slot];
+ while (next != bucket)
{
- WeakBucket prev = buckets[slot];
- /* This may throw a NullPointerException. It shouldn't but if
- * a race condition occurred (two threads removing the same
- * bucket at the same time) it may happen. <br>
- * But with race condition many much worse things may happen
- * anyway.
- */
- while (prev.next != bucket)
- prev = prev.next;
- prev.next = bucket.next;
+ if (next == null) throw new InternalError("WeakHashMap in incosistent state");
+ prev = next;
+ next = prev.next;
}
+ if (prev == null)
+ buckets[slot] = bucket.next;
+ else
+ prev.next = bucket.next;
+
size--;
}