From 8f523f3a1047919d3563daf1ef47ba87336ebe89 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 15 Nov 2005 23:20:01 +0000 Subject: Imported GNU Classpath 0.19 + gcj-import-20051115. * sources.am: Regenerated. * Makefile.in: Likewise. * scripts/makemake.tcl: Use glob -nocomplain. From-SVN: r107049 --- libjava/classpath/java/util/WeakHashMap.java | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'libjava/classpath/java/util/WeakHashMap.java') 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.
- * 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--; } -- cgit v1.2.3