--- jsr166/src/test/tck/CompletableFutureTest.java 2016/06/26 19:17:08 1.153 +++ jsr166/src/test/tck/CompletableFutureTest.java 2016/06/26 19:27:42 1.154 @@ -3317,15 +3317,23 @@ public class CompletableFutureTest exten assertEquals(0, exec.count.get()); } + static class CountingRejectingExecutor implements Executor { + final RejectedExecutionException ex = new RejectedExecutionException(); + final AtomicInteger count = new AtomicInteger(0); + public void execute(Runnable r) { + count.getAndIncrement(); + throw ex; + } + } + /** * Test submissions to an executor that rejects all tasks. */ public void testRejectingExecutor() { - final RejectedExecutionException ex = new RejectedExecutionException(); - final Executor e = (Runnable r) -> { throw ex; }; - for (Integer v : new Integer[] { 1, null }) { + final CountingRejectingExecutor e = new CountingRejectingExecutor(); + final CompletableFuture complete = CompletableFuture.completedFuture(v); final CompletableFuture incomplete = new CompletableFuture<>(); @@ -3355,7 +3363,7 @@ public class CompletableFutureTest exten for (CompletableFuture future : fs) { if (src.isDone()) - checkCompletedWithWrappedException(future, ex); + checkCompletedWithWrappedException(future, e.ex); else checkIncomplete(future); } @@ -3392,14 +3400,17 @@ public class CompletableFutureTest exten fs.add(incomplete.runAfterEitherAsync(complete, () -> {}, e)); for (CompletableFuture future : fs) - checkCompletedWithWrappedException(future, ex); + checkCompletedWithWrappedException(future, e.ex); futures.addAll(fs); } incomplete.complete(v); for (CompletableFuture future : futures) - checkCompletedWithWrappedException(future, ex); + checkCompletedWithWrappedException(future, e.ex); + + assertEquals(futures.size(), e.count.get()); + } } @@ -3409,14 +3420,6 @@ public class CompletableFutureTest exten * explicitly completed. */ public void testRejectingExecutorNeverInvoked() { - final RejectedExecutionException ex = new RejectedExecutionException(); - class CountingRejectingExecutor implements Executor { - final AtomicInteger count = new AtomicInteger(0); - public void execute(Runnable r) { - count.getAndIncrement(); - throw ex; - } - } final CountingRejectingExecutor e = new CountingRejectingExecutor(); for (Integer v : new Integer[] { 1, null }) {