--- jsr166/src/test/tck/JSR166TestCase.java 2015/10/03 21:09:42 1.156 +++ jsr166/src/test/tck/JSR166TestCase.java 2015/10/03 23:17:03 1.158 @@ -191,8 +191,10 @@ public class JSR166TestCase extends Test static volatile TestCase currentTestCase; static { Runnable checkForWedgedTest = new Runnable() { public void run() { + // avoid spurious reports with enormous runsPerTest + final int timeoutMinutes = Math.max(runsPerTest / 10, 1); for (TestCase lastTestCase = currentTestCase;;) { - try { MINUTES.sleep(10); } + try { MINUTES.sleep(timeoutMinutes); } catch (InterruptedException unexpected) { break; } if (lastTestCase == currentTestCase) { System.err.println @@ -539,6 +541,7 @@ public class JSR166TestCase extends Test * the same test have no effect. */ public void threadRecordFailure(Throwable t) { + System.err.println(t); dumpTestThreads(); threadFailure.compareAndSet(null, t); } @@ -767,7 +770,7 @@ public class JSR166TestCase extends Test /** * Allows use of try-with-resources with per-test thread pools. */ - static class PoolCloser + class PoolCloser implements AutoCloseable { public final T pool; public PoolCloser(T pool) { this.pool = pool; } @@ -777,16 +780,23 @@ public class JSR166TestCase extends Test /** * Waits out termination of a thread pool or fails doing so. */ - static void joinPool(ExecutorService pool) { + void joinPool(ExecutorService pool) { try { pool.shutdown(); - if (!pool.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS)) - fail("ExecutorService " + pool + - " did not terminate in a timely manner"); + if (!pool.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS)) { + try { + threadFail("ExecutorService " + pool + + " did not terminate in a timely manner"); + } finally { + // last resort, for the benefit of subsequent tests + pool.shutdownNow(); + pool.awaitTermination(SMALL_DELAY_MS, MILLISECONDS); + } + } } catch (SecurityException ok) { // Allowed in case test doesn't have privs } catch (InterruptedException fail) { - fail("Unexpected InterruptedException"); + threadFail("Unexpected InterruptedException"); } } @@ -858,7 +868,7 @@ public class JSR166TestCase extends Test delay(millis); assertTrue(thread.isAlive()); } catch (InterruptedException fail) { - fail("Unexpected InterruptedException"); + threadFail("Unexpected InterruptedException"); } } @@ -880,7 +890,7 @@ public class JSR166TestCase extends Test for (Thread thread : threads) assertTrue(thread.isAlive()); } catch (InterruptedException fail) { - fail("Unexpected InterruptedException"); + threadFail("Unexpected InterruptedException"); } }