diff -r 6a556bcd94fc -r 1e4270f875ee test/jdk/java/util/concurrent/tck/SemaphoreTest.java --- a/test/jdk/java/util/concurrent/tck/SemaphoreTest.java Sat Sep 14 11:26:26 2019 -0700 +++ b/test/jdk/java/util/concurrent/tck/SemaphoreTest.java Sat Sep 14 11:26:26 2019 -0700 @@ -38,7 +38,6 @@ import java.util.Collection; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Semaphore; -import java.util.concurrent.ThreadLocalRandom; import junit.framework.Test; import junit.framework.TestSuite; @@ -220,24 +219,22 @@ /** * timed tryAcquire times out */ - public void testTryAcquire_timeout() { - final boolean fair = ThreadLocalRandom.current().nextBoolean(); + public void testTryAcquire_timeout() throws InterruptedException { + final boolean fair = randomBoolean(); final Semaphore s = new Semaphore(0, fair); final long startTime = System.nanoTime(); - try { assertFalse(s.tryAcquire(timeoutMillis(), MILLISECONDS)); } - catch (InterruptedException e) { threadUnexpectedException(e); } + assertFalse(s.tryAcquire(timeoutMillis(), MILLISECONDS)); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); } /** * timed tryAcquire(N) times out */ - public void testTryAcquireN_timeout() { - final boolean fair = ThreadLocalRandom.current().nextBoolean(); + public void testTryAcquireN_timeout() throws InterruptedException { + final boolean fair = randomBoolean(); final Semaphore s = new Semaphore(2, fair); final long startTime = System.nanoTime(); - try { assertFalse(s.tryAcquire(3, timeoutMillis(), MILLISECONDS)); } - catch (InterruptedException e) { threadUnexpectedException(e); } + assertFalse(s.tryAcquire(3, timeoutMillis(), MILLISECONDS)); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); }