--- a/test/jdk/java/util/concurrent/tck/PriorityBlockingQueueTest.java Sat Sep 14 11:26:26 2019 -0700
+++ b/test/jdk/java/util/concurrent/tck/PriorityBlockingQueueTest.java Sat Sep 14 11:26:26 2019 -0700
@@ -346,7 +346,7 @@
}
/**
- * timed offer does not time out
+ * Queue is unbounded, so timed offer never times out
*/
public void testTimedOffer() {
final PriorityBlockingQueue q = new PriorityBlockingQueue(2);
@@ -397,7 +397,7 @@
}});
await(pleaseInterrupt);
- assertThreadBlocks(t, Thread.State.WAITING);
+ if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING);
t.interrupt();
awaitTermination(t);
}
@@ -449,29 +449,26 @@
final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
Thread t = newStartedThread(new CheckedRunnable() {
public void realRun() throws InterruptedException {
- long startTime = System.nanoTime();
for (int i = 0; i < SIZE; i++)
assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
Thread.currentThread().interrupt();
try {
- q.poll(LONG_DELAY_MS, MILLISECONDS);
+ q.poll(randomTimeout(), randomTimeUnit());
shouldThrow();
} catch (InterruptedException success) {}
assertFalse(Thread.interrupted());
pleaseInterrupt.countDown();
try {
- q.poll(LONG_DELAY_MS, MILLISECONDS);
+ q.poll(LONGER_DELAY_MS, MILLISECONDS);
shouldThrow();
} catch (InterruptedException success) {}
assertFalse(Thread.interrupted());
-
- assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
}});
await(pleaseInterrupt);
- assertThreadBlocks(t, Thread.State.TIMED_WAITING);
+ if (randomBoolean()) assertThreadBlocks(t, Thread.State.TIMED_WAITING);
t.interrupt();
awaitTermination(t);
}