summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--harmony-tests/src/test/java/org/apache/harmony/tests/java/util/WeakHashMapTest.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/WeakHashMapTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/WeakHashMapTest.java
index 0d34f72..1d5294f 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/WeakHashMapTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/WeakHashMapTest.java
@@ -199,13 +199,18 @@ public class WeakHashMapTest extends junit.framework.TestCase {
values = null;
keyArray[50] = null;
- int count = 0;
+ FinalizationTester.induceFinalization();
+ long startTime = System.currentTimeMillis();
+ // We use a busy wait loop here since we can not know when the ReferenceQueue
+ // daemon will enqueue the cleared references on their internal reference
+ // queues. The current timeout is 5 seconds.
do {
- System.gc();
- System.gc();
- FinalizationTester.induceFinalization();
- count++;
- } while (count <= 5 && entrySet.size() == 100);
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ }
+ } while (entrySet.size() != 99 &&
+ System.currentTimeMillis() - startTime < 5000);
assertTrue(
"Incorrect number of entries returned after gc--wanted 99, got: "