# HG changeset patch # User igerasim # Date 1396426645 -14400 # Node ID f90208c69fb62eeac6546e0b786f74aa6e5c86f9 # Parent b4aba50e2810b8c60219c1cd4482d135ca291ad7 8038333: TEST_BUG: java/lang/ref/EarlyTimeout.java fails with a non-adequate message Reviewed-by: mchung diff -r b4aba50e2810 -r f90208c69fb6 test/java/lang/ref/EarlyTimeout.java --- 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"); } }