--- jsr166/src/test/tck/JSR166TestCase.java 2019/09/22 01:59:57 1.268 +++ jsr166/src/test/tck/JSR166TestCase.java 2020/02/01 18:52:17 1.271 @@ -704,6 +704,13 @@ public class JSR166TestCase extends Test /** * Returns a random element from given choices. */ + T chooseRandomly(List choices) { + return choices.get(ThreadLocalRandom.current().nextInt(choices.size())); + } + + /** + * Returns a random element from given choices. + */ T chooseRandomly(T... choices) { return choices[ThreadLocalRandom.current().nextInt(choices.length)]; } @@ -1193,8 +1200,9 @@ public class JSR166TestCase extends Test } catch (TimeoutException success) { } catch (Exception fail) { threadUnexpectedException(fail); - } finally { future.cancel(true); } + } assertTrue(millisElapsedSince(startTime) >= timeoutMillis); + assertFalse(future.isDone()); } /** @@ -1477,7 +1485,7 @@ public class JSR166TestCase extends Test * wrapped in a CheckedRunnable. */ Thread newStartedThread(Action action) { - return newStartedThread(checkedRunnable(action)); + return newStartedThread(checkedRunnable(action)); } /** @@ -1772,7 +1780,7 @@ public class JSR166TestCase extends Test public int await() { try { - return super.await(2 * LONG_DELAY_MS, MILLISECONDS); + return super.await(LONGER_DELAY_MS, MILLISECONDS); } catch (TimeoutException timedOut) { throw new AssertionError("timed out"); } catch (Exception fail) {