--- jsr166/src/test/tck/JSR166TestCase.java 2015/10/03 19:08:13 1.150 +++ jsr166/src/test/tck/JSR166TestCase.java 2015/10/03 19:39:16 1.154 @@ -519,6 +519,7 @@ public class JSR166TestCase extends Test * the same test have no effect. */ public void threadRecordFailure(Throwable t) { + threadDump(); threadFailure.compareAndSet(null, t); } @@ -529,7 +530,7 @@ public class JSR166TestCase extends Test void tearDownFail(String format, Object... args) { String msg = toString() + ": " + String.format(format, args); System.err.println(msg); - printAllStackTraces(); + threadDump(); throw new AssertionFailedError(msg); } @@ -598,7 +599,7 @@ public class JSR166TestCase extends Test fail(reason); } catch (AssertionFailedError t) { threadRecordFailure(t); - fail(reason); + throw t; } } @@ -778,8 +779,9 @@ public class JSR166TestCase extends Test * necessarily individually slow because they must block. */ void testInParallel(Action ... actions) { - ExecutorService pool = Executors.newCachedThreadPool(); - try { + try (PoolCloser poolCloser + = new PoolCloser<>(Executors.newCachedThreadPool())) { + ExecutorService pool = poolCloser.pool; ArrayList> futures = new ArrayList<>(actions.length); for (final Action action : actions) futures.add(pool.submit(new CheckedRunnable() { @@ -792,8 +794,6 @@ public class JSR166TestCase extends Test } catch (Exception ex) { threadUnexpectedException(ex); } - } finally { - joinPool(pool); } } @@ -801,7 +801,7 @@ public class JSR166TestCase extends Test * A debugging tool to print all stack traces, as jstack does. * Uninteresting threads are filtered out. */ - static void printAllStackTraces() { + static void threadDump() { ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); System.err.println("------ stacktrace dump start ------"); for (ThreadInfo info : threadMXBean.dumpAllThreads(true, true)) {