changeset 9664:e419e57a2426

8038333: TEST_BUG: java/lang/ref/EarlyTimeout.java fails with a non-adequate message Reviewed-by: mchung
author igerasim
date Wed, 02 Apr 2014 12:17:25 +0400
parents b0a3890a0171
children 183cb0db0389
files test/java/lang/ref/EarlyTimeout.java
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/lang/ref/EarlyTimeout.java	Tue Apr 01 17:25:55 2014 -0700
+++ b/test/java/lang/ref/EarlyTimeout.java	Wed Apr 02 12:17:25 2014 +0400
@@ -37,7 +37,7 @@
 /**
  * In order to demonstrate the issue we make several threads (two appears to be sufficient)
  * to block in ReferenceQueue#remove(timeout) at the same time.
- * Then, we force a reference to be enqueued by setting its referent to null and calling System.gs().
+ * Then, we force a reference to be enqueued by setting its referent to null and calling System.gc().
  * One of the threads gets the reference returned from the remove().
  * The other threads get null:
  * 1) with bug:  this may happen before the specified timeout is elapsed,
@@ -63,7 +63,10 @@
             threads[i] = new EarlyTimeout();
             threads[i].start();
         }
+        // The main thread waits until the threads has started and give it a chance
+        // for the threads to block on the queue.remove(TIMEOUT) call
         startedSignal.await();
+        Thread.sleep(TIMEOUT / 2);
         referent = null;
         System.gc();
         for (EarlyTimeout thread : threads) {
@@ -82,7 +85,7 @@
                 nonNullRefCount++;
             }
         }
-        if (nonNullRefCount != 1) {
+        if (nonNullRefCount > 1) {
             throw new RuntimeException("more than one references were removed from queue");
         }
     }