diff options
author | Mathieu Chartier <mathieuc@google.com> | 2014-06-24 19:35:34 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-06-24 19:35:34 +0000 |
commit | 47c61891491acce74675622abf3132ff03464ae5 (patch) | |
tree | 05cd578aab5a3be3d075affe5c7956d993e89251 /harmony-tests | |
parent | cd80a8301b9f5b262d30e982e85820d4dc9685d4 (diff) | |
parent | 31e8ef04eb3bc2029eb94393c3ce87245dd75da2 (diff) | |
download | libcore-47c61891491acce74675622abf3132ff03464ae5.zip libcore-47c61891491acce74675622abf3132ff03464ae5.tar.gz libcore-47c61891491acce74675622abf3132ff03464ae5.tar.bz2 |
am 31e8ef04: Merge "Fix race condition in WeakHashMapTest."
* commit '31e8ef04eb3bc2029eb94393c3ce87245dd75da2':
Fix race condition in WeakHashMapTest.
Diffstat (limited to 'harmony-tests')
-rw-r--r-- | harmony-tests/src/test/java/org/apache/harmony/tests/java/util/WeakHashMapTest.java | 17 |
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: " |