--- jsr166/src/test/tck/CompletableFutureTest.java 2014/06/16 17:41:26 1.81 +++ jsr166/src/test/tck/CompletableFutureTest.java 2014/06/16 18:04:07 1.82 @@ -3118,6 +3118,31 @@ public class CompletableFutureTest exten assertSame(f, f.toCompletableFuture()); } + //--- tests of implementation details; not part of official tck --- + + Object resultOf(CompletableFuture f) { + try { + java.lang.reflect.Field resultField + = CompletableFuture.class.getDeclaredField("result"); + resultField.setAccessible(true); + return resultField.get(f); + } catch (Throwable t) { throw new AssertionError(t); } + } + + public void testExceptionPropagationReusesResultObject() { + if (!testImplementationDetails) return; + for (ExecutionMode m : ExecutionMode.values()) + { + final CompletableFuture f = new CompletableFuture<>(); + CFException ex = new CFException(); + f.completeExceptionally(ex); + final CompletableFuture g = f.thenRun(new Noop(m)); + checkCompletedWithWrappedException(g, ex); + final CompletableFuture h = g.thenRun(new Noop(m)); + checkCompletedWithWrappedException(h, ex); + assertSame(resultOf(g), resultOf(h)); + }} + // public void testRunAfterEither_resultDeterminedAtTimeOfCreation() { // for (ExecutionMode m : ExecutionMode.values()) // for (boolean mayInterruptIfRunning : new boolean[] { true, false })