--- jsr166/src/test/tck/CompletableFutureTest.java 2013/03/21 16:26:43 1.5 +++ jsr166/src/test/tck/CompletableFutureTest.java 2013/04/01 20:06:25 1.14 @@ -53,7 +53,7 @@ public class CompletableFutureTest exten catch (Throwable fail) { threadUnexpectedException(fail); } } - void checkCompletedNormally(CompletableFuture f, Object value) { + void checkCompletedNormally(CompletableFuture f, T value) { try { assertEquals(value, f.join()); } catch (Throwable fail) { threadUnexpectedException(fail); } @@ -75,95 +75,84 @@ public class CompletableFutureTest exten try { f.join(); shouldThrow(); - } catch (Throwable ex) { - assertTrue(ex instanceof CompletionException && - ((CompletionException)ex).getCause() instanceof CFException); + } catch (CompletionException success) { + assertTrue(success.getCause() instanceof CFException); } try { f.getNow(null); shouldThrow(); - } catch (Throwable ex) { - assertTrue(ex instanceof CompletionException && - ((CompletionException)ex).getCause() instanceof CFException); + } catch (CompletionException success) { + assertTrue(success.getCause() instanceof CFException); } try { f.get(); shouldThrow(); - } catch (Throwable ex) { - assertTrue(ex instanceof ExecutionException && - ((ExecutionException)ex).getCause() instanceof CFException); - } + } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof CFException); + } catch (Throwable fail) { threadUnexpectedException(fail); } try { f.get(0L, SECONDS); shouldThrow(); - } catch (Throwable ex) { - assertTrue(ex instanceof ExecutionException && - ((ExecutionException)ex).getCause() instanceof CFException); - } + } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof CFException); + } catch (Throwable fail) { threadUnexpectedException(fail); } assertTrue(f.isDone()); assertFalse(f.isCancelled()); + assertTrue(f.toString().contains("[Completed exceptionally]")); } void checkCancelled(CompletableFuture f) { try { f.join(); shouldThrow(); - } catch (Throwable ex) { - assertTrue(ex instanceof CancellationException); - } + } catch (CancellationException success) {} try { f.getNow(null); shouldThrow(); - } catch (Throwable ex) { - assertTrue(ex instanceof CancellationException); - } + } catch (CancellationException success) {} try { f.get(); shouldThrow(); - } catch (Throwable ex) { - assertTrue(ex instanceof CancellationException); - } + } catch (CancellationException success) { + } catch (Throwable fail) { threadUnexpectedException(fail); } try { f.get(0L, SECONDS); shouldThrow(); - } catch (Throwable ex) { - assertTrue(ex instanceof CancellationException); - } + } catch (CancellationException success) { + } catch (Throwable fail) { threadUnexpectedException(fail); } assertTrue(f.isDone()); assertTrue(f.isCancelled()); + assertTrue(f.toString().contains("[Completed exceptionally]")); } void checkCompletedWithWrappedCancellationException(CompletableFuture f) { try { f.join(); shouldThrow(); - } catch (Throwable ex) { - assertTrue(ex instanceof CompletionException && - ((CompletionException)ex).getCause() instanceof CancellationException); + } catch (CompletionException success) { + assertTrue(success.getCause() instanceof CancellationException); } try { f.getNow(null); shouldThrow(); - } catch (Throwable ex) { - assertTrue(ex instanceof CompletionException && - ((CompletionException)ex).getCause() instanceof CancellationException); + } catch (CompletionException success) { + assertTrue(success.getCause() instanceof CancellationException); } try { f.get(); shouldThrow(); - } catch (Throwable ex) { - assertTrue(ex instanceof ExecutionException && - ((ExecutionException)ex).getCause() instanceof CancellationException); - } + } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof CancellationException); + } catch (Throwable fail) { threadUnexpectedException(fail); } try { f.get(0L, SECONDS); shouldThrow(); - } catch (Throwable ex) { - assertTrue(ex instanceof ExecutionException && - ((ExecutionException)ex).getCause() instanceof CancellationException); - } + } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof CancellationException); + } catch (Throwable fail) { threadUnexpectedException(fail); } assertTrue(f.isDone()); assertFalse(f.isCancelled()); + assertTrue(f.toString().contains("[Completed exceptionally]")); } /** @@ -249,7 +238,7 @@ public class CompletableFutureTest exten f.obtrudeException(new CFException()); checkCompletedWithWrappedCFException(f); } - + /** * getNumberOfDependents returns number of dependent tasks */ @@ -285,11 +274,19 @@ public class CompletableFutureTest exten assertTrue(f.toString().contains("[Completed exceptionally]")); } - static final Supplier supplyOne = + /** + * completedFuture returns a completed CompletableFuture with given value + */ + public void testCompletedFuture() { + CompletableFuture f = CompletableFuture.completedFuture("test"); + checkCompletedNormally(f, "test"); + } + + static final Supplier supplyOne = () -> Integer.valueOf(1); - static final Function inc = + static final Function inc = (Integer x) -> Integer.valueOf(x.intValue() + 1); - static final BiFunction add = + static final BiFunction add = (Integer x, Integer y) -> Integer.valueOf(x.intValue() + y.intValue()); static final class IncAction implements Consumer { int value; @@ -297,8 +294,8 @@ public class CompletableFutureTest exten } static final class AddAction implements BiConsumer { int value; - public void accept(Integer x, Integer y) { - value = x.intValue() + y.intValue(); + public void accept(Integer x, Integer y) { + value = x.intValue() + y.intValue(); } } static final class Noop implements Runnable { @@ -345,7 +342,7 @@ public class CompletableFutureTest exten ran = true; throw new CFException(); } } - + // Used for explicit executor tests static final class ThreadExecutor implements Executor { public void execute(Runnable r) { @@ -358,7 +355,7 @@ public class CompletableFutureTest exten } static final class IntegerHandler implements BiFunction { - public Integer apply(Integer x, Throwable t) { + public Integer apply(Integer x, Throwable t) { return (t == null) ? two : three; } } @@ -408,6 +405,7 @@ public class CompletableFutureTest exten CompletableFuture f = CompletableFuture.runAsync(r); assertNull(f.join()); assertTrue(r.ran); + checkCompletedNormally(f, null); } /** @@ -418,6 +416,7 @@ public class CompletableFutureTest exten CompletableFuture f = CompletableFuture.runAsync(r, new ThreadExecutor()); assertNull(f.join()); assertTrue(r.ran); + checkCompletedNormally(f, null); } /** @@ -456,8 +455,8 @@ public class CompletableFutureTest exten assertTrue(r.ran); } - // seq conmpletion methods - + // seq completion methods + /** * thenRun result completes normally after normal completion of source */ @@ -1126,7 +1125,7 @@ public class CompletableFutureTest exten try { g.join(); shouldThrow(); - } catch(Exception ok) { + } catch (Exception ok) { } checkCompletedWithWrappedCFException(g); } @@ -1141,7 +1140,7 @@ public class CompletableFutureTest exten f.complete(null); checkCompletedWithWrappedCFException(g); } - + /** * thenRunAsync result completes exceptionally if source cancelled */ @@ -1184,7 +1183,7 @@ public class CompletableFutureTest exten f.complete(null); checkCompletedWithWrappedCFException(g); } - + /** * thenApplyAsync result completes exceptionally if source cancelled */ @@ -1230,7 +1229,7 @@ public class CompletableFutureTest exten f.complete(null); checkCompletedWithWrappedCFException(g); } - + /** * thenAcceptAsync result completes exceptionally if source cancelled */ @@ -1288,7 +1287,7 @@ public class CompletableFutureTest exten f2.complete(two); checkCompletedWithWrappedCFException(g); } - + /** * thenCombineAsync result completes exceptionally if either source cancelled */ @@ -1299,7 +1298,7 @@ public class CompletableFutureTest exten assertTrue(f.cancel(true)); f2.complete(two); checkCompletedWithWrappedCancellationException(g); - + f = new CompletableFuture(); f2 = new CompletableFuture(); g = f.thenCombineAsync(f2, add); @@ -1353,13 +1352,13 @@ public class CompletableFutureTest exten CompletableFuture f = new CompletableFuture(); CompletableFuture f2 = new CompletableFuture(); FailingBiConsumer r = new FailingBiConsumer(); - CompletableFuture g = f.thenAcceptBothAsync(f2, r); + CompletableFuture g = f.thenAcceptBothAsync(f2, r); f.complete(one); checkIncomplete(g); f2.complete(two); checkCompletedWithWrappedCFException(g); } - + /** * thenAcceptBothAsync result completes exceptionally if either source cancelled */ @@ -1371,7 +1370,7 @@ public class CompletableFutureTest exten assertTrue(f.cancel(true)); f2.complete(two); checkCompletedWithWrappedCancellationException(g); - + r = new AddAction(); f = new CompletableFuture(); f2 = new CompletableFuture(); @@ -1426,13 +1425,13 @@ public class CompletableFutureTest exten CompletableFuture f = new CompletableFuture(); CompletableFuture f2 = new CompletableFuture(); FailingNoop r = new FailingNoop(); - CompletableFuture g = f.runAfterBothAsync(f2, r); + CompletableFuture g = f.runAfterBothAsync(f2, r); f.complete(one); checkIncomplete(g); f2.complete(two); checkCompletedWithWrappedCFException(g); } - + /** * runAfterBothAsync result completes exceptionally if either source cancelled */ @@ -1444,7 +1443,7 @@ public class CompletableFutureTest exten assertTrue(f.cancel(true)); f2.complete(two); checkCompletedWithWrappedCancellationException(g); - + r = new Noop(); f = new CompletableFuture(); f2 = new CompletableFuture(); @@ -1498,11 +1497,11 @@ public class CompletableFutureTest exten CompletableFuture f = new CompletableFuture(); CompletableFuture f2 = new CompletableFuture(); FailingFunction r = new FailingFunction(); - CompletableFuture g = f.applyToEitherAsync(f2, r); + CompletableFuture g = f.applyToEitherAsync(f2, r); f.complete(one); checkCompletedWithWrappedCFException(g); } - + /** * applyToEitherAsync result completes exceptionally if either source cancelled */ @@ -1512,7 +1511,7 @@ public class CompletableFutureTest exten CompletableFuture g = f.applyToEitherAsync(f2, inc); assertTrue(f.cancel(true)); checkCompletedWithWrappedCancellationException(g); - + f = new CompletableFuture(); f2 = new CompletableFuture(); assertTrue(f2.cancel(true)); @@ -1570,11 +1569,11 @@ public class CompletableFutureTest exten CompletableFuture f = new CompletableFuture(); CompletableFuture f2 = new CompletableFuture(); FailingConsumer r = new FailingConsumer(); - CompletableFuture g = f.acceptEitherAsync(f2, r); + CompletableFuture g = f.acceptEitherAsync(f2, r); f.complete(one); checkCompletedWithWrappedCFException(g); } - + /** * acceptEitherAsync result completes exceptionally if either * source cancelled @@ -1586,7 +1585,7 @@ public class CompletableFutureTest exten CompletableFuture g = f.acceptEitherAsync(f2, r); assertTrue(f.cancel(true)); checkCompletedWithWrappedCancellationException(g); - + r = new IncAction(); f = new CompletableFuture(); f2 = new CompletableFuture(); @@ -1645,11 +1644,11 @@ public class CompletableFutureTest exten CompletableFuture f = new CompletableFuture(); CompletableFuture f2 = new CompletableFuture(); FailingNoop r = new FailingNoop(); - CompletableFuture g = f.runAfterEitherAsync(f2, r); + CompletableFuture g = f.runAfterEitherAsync(f2, r); f.complete(one); checkCompletedWithWrappedCFException(g); } - + /** * runAfterEitherAsync result completes exceptionally if either * source cancelled @@ -1661,7 +1660,7 @@ public class CompletableFutureTest exten CompletableFuture g = f.runAfterEitherAsync(f2, r); assertTrue(f.cancel(true)); checkCompletedWithWrappedCancellationException(g); - + r = new Noop(); f = new CompletableFuture(); f2 = new CompletableFuture(); @@ -1671,7 +1670,8 @@ public class CompletableFutureTest exten } /** - * thenCompse result completes normally after normal completion of source + * thenComposeAsync result completes normally after normal + * completion of source */ public void testThenComposeAsync() { CompletableFuture f = new CompletableFuture(); @@ -1682,8 +1682,8 @@ public class CompletableFutureTest exten } /** - * thenComposeAsync result completes exceptionally after exceptional - * completion of source + * thenComposeAsync result completes exceptionally after + * exceptional completion of source */ public void testThenComposeAsync2() { CompletableFuture f = new CompletableFuture(); @@ -1716,7 +1716,7 @@ public class CompletableFutureTest exten } - // aaync with explicit executors + // async with explicit executors /** * thenRunAsync result completes normally after normal completion of source @@ -1748,7 +1748,7 @@ public class CompletableFutureTest exten try { g.join(); shouldThrow(); - } catch(Exception ok) { + } catch (Exception ok) { } checkCompletedWithWrappedCFException(g); } @@ -1763,7 +1763,7 @@ public class CompletableFutureTest exten f.complete(null); checkCompletedWithWrappedCFException(g); } - + /** * thenRunAsync result completes exceptionally if source cancelled */ @@ -1806,7 +1806,7 @@ public class CompletableFutureTest exten f.complete(null); checkCompletedWithWrappedCFException(g); } - + /** * thenApplyAsync result completes exceptionally if source cancelled */ @@ -1852,7 +1852,7 @@ public class CompletableFutureTest exten f.complete(null); checkCompletedWithWrappedCFException(g); } - + /** * thenAcceptAsync result completes exceptionally if source cancelled */ @@ -1910,7 +1910,7 @@ public class CompletableFutureTest exten f2.complete(two); checkCompletedWithWrappedCFException(g); } - + /** * thenCombineAsync result completes exceptionally if either source cancelled */ @@ -1921,7 +1921,7 @@ public class CompletableFutureTest exten assertTrue(f.cancel(true)); f2.complete(two); checkCompletedWithWrappedCancellationException(g); - + f = new CompletableFuture(); f2 = new CompletableFuture(); g = f.thenCombineAsync(f2, add, new ThreadExecutor()); @@ -1975,13 +1975,13 @@ public class CompletableFutureTest exten CompletableFuture f = new CompletableFuture(); CompletableFuture f2 = new CompletableFuture(); FailingBiConsumer r = new FailingBiConsumer(); - CompletableFuture g = f.thenAcceptBothAsync(f2, r, new ThreadExecutor()); + CompletableFuture g = f.thenAcceptBothAsync(f2, r, new ThreadExecutor()); f.complete(one); checkIncomplete(g); f2.complete(two); checkCompletedWithWrappedCFException(g); } - + /** * thenAcceptBothAsync result completes exceptionally if either source cancelled */ @@ -1993,7 +1993,7 @@ public class CompletableFutureTest exten assertTrue(f.cancel(true)); f2.complete(two); checkCompletedWithWrappedCancellationException(g); - + r = new AddAction(); f = new CompletableFuture(); f2 = new CompletableFuture(); @@ -2048,13 +2048,13 @@ public class CompletableFutureTest exten CompletableFuture f = new CompletableFuture(); CompletableFuture f2 = new CompletableFuture(); FailingNoop r = new FailingNoop(); - CompletableFuture g = f.runAfterBothAsync(f2, r, new ThreadExecutor()); + CompletableFuture g = f.runAfterBothAsync(f2, r, new ThreadExecutor()); f.complete(one); checkIncomplete(g); f2.complete(two); checkCompletedWithWrappedCFException(g); } - + /** * runAfterBothAsync result completes exceptionally if either source cancelled */ @@ -2066,7 +2066,7 @@ public class CompletableFutureTest exten assertTrue(f.cancel(true)); f2.complete(two); checkCompletedWithWrappedCancellationException(g); - + r = new Noop(); f = new CompletableFuture(); f2 = new CompletableFuture(); @@ -2120,11 +2120,11 @@ public class CompletableFutureTest exten CompletableFuture f = new CompletableFuture(); CompletableFuture f2 = new CompletableFuture(); FailingFunction r = new FailingFunction(); - CompletableFuture g = f.applyToEitherAsync(f2, r, new ThreadExecutor()); + CompletableFuture g = f.applyToEitherAsync(f2, r, new ThreadExecutor()); f.complete(one); checkCompletedWithWrappedCFException(g); } - + /** * applyToEitherAsync result completes exceptionally if either source cancelled */ @@ -2134,7 +2134,7 @@ public class CompletableFutureTest exten CompletableFuture g = f.applyToEitherAsync(f2, inc, new ThreadExecutor()); assertTrue(f.cancel(true)); checkCompletedWithWrappedCancellationException(g); - + f = new CompletableFuture(); f2 = new CompletableFuture(); assertTrue(f2.cancel(true)); @@ -2192,11 +2192,11 @@ public class CompletableFutureTest exten CompletableFuture f = new CompletableFuture(); CompletableFuture f2 = new CompletableFuture(); FailingConsumer r = new FailingConsumer(); - CompletableFuture g = f.acceptEitherAsync(f2, r, new ThreadExecutor()); + CompletableFuture g = f.acceptEitherAsync(f2, r, new ThreadExecutor()); f.complete(one); checkCompletedWithWrappedCFException(g); } - + /** * acceptEitherAsync result completes exceptionally if either * source cancelled @@ -2208,7 +2208,7 @@ public class CompletableFutureTest exten CompletableFuture g = f.acceptEitherAsync(f2, r, new ThreadExecutor()); assertTrue(f.cancel(true)); checkCompletedWithWrappedCancellationException(g); - + r = new IncAction(); f = new CompletableFuture(); f2 = new CompletableFuture(); @@ -2267,11 +2267,11 @@ public class CompletableFutureTest exten CompletableFuture f = new CompletableFuture(); CompletableFuture f2 = new CompletableFuture(); FailingNoop r = new FailingNoop(); - CompletableFuture g = f.runAfterEitherAsync(f2, r, new ThreadExecutor()); + CompletableFuture g = f.runAfterEitherAsync(f2, r, new ThreadExecutor()); f.complete(one); checkCompletedWithWrappedCFException(g); } - + /** * runAfterEitherAsync result completes exceptionally if either * source cancelled @@ -2283,7 +2283,7 @@ public class CompletableFutureTest exten CompletableFuture g = f.runAfterEitherAsync(f2, r, new ThreadExecutor()); assertTrue(f.cancel(true)); checkCompletedWithWrappedCancellationException(g); - + r = new Noop(); f = new CompletableFuture(); f2 = new CompletableFuture(); @@ -2293,7 +2293,8 @@ public class CompletableFutureTest exten } /** - * thenCompse result completes normally after normal completion of source + * thenComposeAsync result completes normally after normal + * completion of source */ public void testThenComposeAsyncE() { CompletableFuture f = new CompletableFuture(); @@ -2304,8 +2305,8 @@ public class CompletableFutureTest exten } /** - * thenComposeAsync result completes exceptionally after exceptional - * completion of source + * thenComposeAsync result completes exceptionally after + * exceptional completion of source */ public void testThenComposeAsync2E() { CompletableFuture f = new CompletableFuture(); @@ -2337,7 +2338,7 @@ public class CompletableFutureTest exten checkCompletedWithWrappedCancellationException(g); } - // other static methods + // other static methods /** * allOf(no component futures) returns a future completed normally @@ -2354,15 +2355,14 @@ public class CompletableFutureTest exten public void testAllOf() throws Exception { for (int k = 1; k < 20; ++k) { CompletableFuture[] fs = new CompletableFuture[k]; - for (int i = 0; i < k; ++i) + for (int i = 0; i < k; ++i) fs[i] = new CompletableFuture(); - CompletableFuture f = CompletableFuture.allOf(fs); + CompletableFuture f = CompletableFuture.allOf(fs); for (int i = 0; i < k; ++i) { checkIncomplete(f); fs[i].complete(one); } - assertTrue(f.isDone()); - assertFalse(f.isCancelled()); + checkCompletedNormally(f, null); } } @@ -2375,18 +2375,18 @@ public class CompletableFutureTest exten } /** - * allOf returns a future completed when any components complete + * anyOf returns a future completed when any components complete */ public void testAnyOf() throws Exception { for (int k = 1; k < 20; ++k) { CompletableFuture[] fs = new CompletableFuture[k]; - for (int i = 0; i < k; ++i) + for (int i = 0; i < k; ++i) fs[i] = new CompletableFuture(); - CompletableFuture f = CompletableFuture.anyOf(fs); + CompletableFuture f = CompletableFuture.anyOf(fs); checkIncomplete(f); for (int i = 0; i < k; ++i) { fs[i].complete(one); - assertTrue(f.isDone()); + checkCompletedNormally(f, one); } } } @@ -2397,39 +2397,110 @@ public class CompletableFutureTest exten public void testNPE() { CompletableFuture f = new CompletableFuture(); CompletableFuture g = new CompletableFuture(); - CompletableFuture h; - try { h = f.thenApply(null); } catch (NullPointerException ok) {} - try { h = f.thenAccept(null); } catch (NullPointerException ok) {} - try { h = f.thenRun(null); } catch (NullPointerException ok) {} - try { h = f.thenCombine(g, null); } catch (NullPointerException ok) {} - try { h = f.thenCombine(null, null); } catch (NullPointerException ok) {} - try { h = f.applyToEither(g, null); } catch (NullPointerException ok) {} - try { h = f.applyToEither(null, null); } catch (NullPointerException ok) {} - try { h = f.thenAcceptBoth(g, null); } catch (NullPointerException ok) {} - try { h = f.thenAcceptBoth(null, null); } catch (NullPointerException ok) {} - try { h = f.runAfterEither(g, null); } catch (NullPointerException ok) {} - try { h = f.runAfterEither(null, null); } catch (NullPointerException ok) {} - try { h = f.runAfterBoth(g, null); } catch (NullPointerException ok) {} - try { h = f.runAfterBoth(null, null); } catch (NullPointerException ok) {} - try { h = f.exceptionally(null); } catch (NullPointerException ok) {} - try { h = f.handle(null); } catch (NullPointerException ok) {} - try { h = f.thenCompose(null); } catch (NullPointerException ok) {} - - try { h = f.thenApplyAsync(null); } catch (NullPointerException ok) {} - try { h = f.thenAcceptAsync(null); } catch (NullPointerException ok) {} - try { h = f.thenRunAsync(null); } catch (NullPointerException ok) {} - try { h = f.thenCombineAsync(g, null); } catch (NullPointerException ok) {} - try { h = f.thenCombineAsync(null, null); } catch (NullPointerException ok) {} - try { h = f.applyToEitherAsync(g, null); } catch (NullPointerException ok) {} - try { h = f.applyToEitherAsync(null, null); } catch (NullPointerException ok) {} - try { h = f.thenAcceptBothAsync(g, null); } catch (NullPointerException ok) {} - try { h = f.thenAcceptBothAsync(null, null); } catch (NullPointerException ok) {} - try { h = f.runAfterEitherAsync(g, null); } catch (NullPointerException ok) {} - try { h = f.runAfterEitherAsync(null, null); } catch (NullPointerException ok) {} - try { h = f.runAfterBothAsync(g, null); } catch (NullPointerException ok) {} - try { h = f.runAfterBothAsync(null, null); } catch (NullPointerException ok) {} + CompletableFuture nullFuture = (CompletableFuture)null; + CompletableFuture h; + Executor exec = new ThreadExecutor(); + + Runnable[] throwingActions = { + () -> { CompletableFuture.supplyAsync(null); }, + () -> { CompletableFuture.supplyAsync(null, exec); }, + () -> { CompletableFuture.supplyAsync(() -> one, null); }, + + () -> { CompletableFuture.runAsync(null); }, + () -> { CompletableFuture.runAsync(null, exec); }, + () -> { CompletableFuture.runAsync(() -> {}, null); }, + + () -> { f.completeExceptionally(null); }, + + () -> { f.thenApply(null); }, + () -> { f.thenApplyAsync(null); }, + () -> { f.thenApplyAsync((x) -> x, null); }, + () -> { f.thenApplyAsync(null, exec); }, + + () -> { f.thenAccept(null); }, + () -> { f.thenAcceptAsync(null); }, + () -> { f.thenAcceptAsync((x) -> { ; }, null); }, + () -> { f.thenAcceptAsync(null, exec); }, + + () -> { f.thenRun(null); }, + () -> { f.thenRunAsync(null); }, + () -> { f.thenRunAsync(() -> { ; }, null); }, + () -> { f.thenRunAsync(null, exec); }, + + () -> { f.thenCombine(g, null); }, + () -> { f.thenCombineAsync(g, null); }, + () -> { f.thenCombineAsync(g, null, exec); }, + () -> { f.thenCombine(nullFuture, (x, y) -> x); }, + () -> { f.thenCombineAsync(nullFuture, (x, y) -> x); }, + () -> { f.thenCombineAsync(nullFuture, (x, y) -> x, exec); }, + () -> { f.thenCombineAsync(g, (x, y) -> x, null); }, + + () -> { f.thenAcceptBoth(g, null); }, + () -> { f.thenAcceptBothAsync(g, null); }, + () -> { f.thenAcceptBothAsync(g, null, exec); }, + () -> { f.thenAcceptBoth(nullFuture, (x, y) -> {}); }, + () -> { f.thenAcceptBothAsync(nullFuture, (x, y) -> {}); }, + () -> { f.thenAcceptBothAsync(nullFuture, (x, y) -> {}, exec); }, + () -> { f.thenAcceptBothAsync(g, (x, y) -> {}, null); }, + + () -> { f.runAfterBoth(g, null); }, + () -> { f.runAfterBothAsync(g, null); }, + () -> { f.runAfterBothAsync(g, null, exec); }, + () -> { f.runAfterBoth(nullFuture, () -> {}); }, + () -> { f.runAfterBothAsync(nullFuture, () -> {}); }, + () -> { f.runAfterBothAsync(nullFuture, () -> {}, exec); }, + () -> { f.runAfterBothAsync(g, () -> {}, null); }, + + () -> { f.applyToEither(g, null); }, + () -> { f.applyToEitherAsync(g, null); }, + () -> { f.applyToEitherAsync(g, null, exec); }, + () -> { f.applyToEither(nullFuture, (x) -> x); }, + () -> { f.applyToEitherAsync(nullFuture, (x) -> x); }, + () -> { f.applyToEitherAsync(nullFuture, (x) -> x, exec); }, + () -> { f.applyToEitherAsync(g, (x) -> x, null); }, + + () -> { f.acceptEither(g, null); }, + () -> { f.acceptEitherAsync(g, null); }, + () -> { f.acceptEitherAsync(g, null, exec); }, + () -> { f.acceptEither(nullFuture, (x) -> {}); }, + () -> { f.acceptEitherAsync(nullFuture, (x) -> {}); }, + () -> { f.acceptEitherAsync(nullFuture, (x) -> {}, exec); }, + () -> { f.acceptEitherAsync(g, (x) -> {}, null); }, + + () -> { f.runAfterEither(g, null); }, + () -> { f.runAfterEitherAsync(g, null); }, + () -> { f.runAfterEitherAsync(g, null, exec); }, + () -> { f.runAfterEither(nullFuture, () -> {}); }, + () -> { f.runAfterEitherAsync(nullFuture, () -> {}); }, + () -> { f.runAfterEitherAsync(nullFuture, () -> {}, exec); }, + () -> { f.runAfterEitherAsync(g, () -> {}, null); }, + + () -> { f.thenCompose(null); }, + () -> { f.thenComposeAsync(null); }, + () -> { f.thenComposeAsync(new CompletableFutureInc(), null); }, + () -> { f.thenComposeAsync(null, exec); }, + + () -> { f.exceptionally(null); }, + + () -> { f.handle(null); }, + + () -> { CompletableFuture.allOf((CompletableFuture)null); }, + () -> { CompletableFuture.allOf((CompletableFuture[])null); }, + () -> { CompletableFuture.allOf(f, null); }, + () -> { CompletableFuture.allOf(null, f); }, + + () -> { CompletableFuture.anyOf((CompletableFuture)null); }, + () -> { CompletableFuture.anyOf((CompletableFuture[])null); }, + () -> { CompletableFuture.anyOf(f, null); }, + () -> { CompletableFuture.anyOf(null, f); }, + + // TODO: Crashes javac with lambda-8-2013-03-31... + //() -> { CompletableFuture x = f.thenAccept(null); }, + //() -> { CompletableFuture x = f.thenRun(null); }, + //() -> { CompletableFuture x = f.thenApply(() -> { ; }); }, + }; + assertThrows(NullPointerException.class, throwingActions); } - }