Mercurial > hg > shenandoah-preopenjdk-archive > openjdk8 > jdk
changeset 10249:f90208c69fb6
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 | b4aba50e2810 |
children | a73b9a26a9ae |
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 Thu Feb 27 02:44:04 2014 +0400 +++ 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"); } }