--- jsr166/src/test/tck/CompletableFutureTest.java 2016/09/22 22:05:49 1.179 +++ jsr166/src/test/tck/CompletableFutureTest.java 2016/11/06 22:42:10 1.180 @@ -147,26 +147,26 @@ public class CompletableFutureTest exten void checkCompletedWithWrappedCFException(CompletableFuture f) { checkCompletedExceptionally(f, true, - (t) -> assertTrue(t instanceof CFException)); + t -> assertTrue(t instanceof CFException)); } void checkCompletedWithWrappedCancellationException(CompletableFuture f) { checkCompletedExceptionally(f, true, - (t) -> assertTrue(t instanceof CancellationException)); + t -> assertTrue(t instanceof CancellationException)); } void checkCompletedWithTimeoutException(CompletableFuture f) { checkCompletedExceptionally(f, false, - (t) -> assertTrue(t instanceof TimeoutException)); + t -> assertTrue(t instanceof TimeoutException)); } void checkCompletedWithWrappedException(CompletableFuture f, Throwable ex) { - checkCompletedExceptionally(f, true, (t) -> assertSame(t, ex)); + checkCompletedExceptionally(f, true, t -> assertSame(t, ex)); } void checkCompletedExceptionally(CompletableFuture f, Throwable ex) { - checkCompletedExceptionally(f, false, (t) -> assertSame(t, ex)); + checkCompletedExceptionally(f, false, t -> assertSame(t, ex)); } void checkCancelled(CompletableFuture f) { @@ -3257,12 +3257,12 @@ public class CompletableFutureTest exten () -> f.thenApply(null), () -> f.thenApplyAsync(null), - () -> f.thenApplyAsync((x) -> x, null), + () -> f.thenApplyAsync(x -> x, null), () -> f.thenApplyAsync(null, exec), () -> f.thenAccept(null), () -> f.thenAcceptAsync(null), - () -> f.thenAcceptAsync((x) -> {} , null), + () -> f.thenAcceptAsync(x -> {} , null), () -> f.thenAcceptAsync(null, exec), () -> f.thenRun(null), @@ -3297,18 +3297,18 @@ public class CompletableFutureTest exten () -> 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.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.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), @@ -3374,18 +3374,18 @@ public class CompletableFutureTest exten for (CompletableFuture src : srcs) { List> fs = new ArrayList<>(); fs.add(src.thenRunAsync(() -> {}, e)); - fs.add(src.thenAcceptAsync((z) -> {}, e)); - fs.add(src.thenApplyAsync((z) -> z, e)); + fs.add(src.thenAcceptAsync(z -> {}, e)); + fs.add(src.thenApplyAsync(z -> z, e)); fs.add(src.thenCombineAsync(src, (x, y) -> x, e)); fs.add(src.thenAcceptBothAsync(src, (x, y) -> {}, e)); fs.add(src.runAfterBothAsync(src, () -> {}, e)); - fs.add(src.applyToEitherAsync(src, (z) -> z, e)); - fs.add(src.acceptEitherAsync(src, (z) -> {}, e)); + fs.add(src.applyToEitherAsync(src, z -> z, e)); + fs.add(src.acceptEitherAsync(src, z -> {}, e)); fs.add(src.runAfterEitherAsync(src, () -> {}, e)); - fs.add(src.thenComposeAsync((z) -> null, e)); + fs.add(src.thenComposeAsync(z -> null, e)); fs.add(src.whenCompleteAsync((z, t) -> {}, e)); fs.add(src.handleAsync((z, t) -> null, e)); @@ -3418,11 +3418,11 @@ public class CompletableFutureTest exten { List> fs = new ArrayList<>(); - fs.add(complete.applyToEitherAsync(incomplete, (z) -> z, e)); - fs.add(incomplete.applyToEitherAsync(complete, (z) -> z, e)); + fs.add(complete.applyToEitherAsync(incomplete, z -> z, e)); + fs.add(incomplete.applyToEitherAsync(complete, z -> z, e)); - fs.add(complete.acceptEitherAsync(incomplete, (z) -> {}, e)); - fs.add(incomplete.acceptEitherAsync(complete, (z) -> {}, e)); + fs.add(complete.acceptEitherAsync(incomplete, z -> {}, e)); + fs.add(incomplete.acceptEitherAsync(complete, z -> {}, e)); fs.add(complete.runAfterEitherAsync(incomplete, () -> {}, e)); fs.add(incomplete.runAfterEitherAsync(complete, () -> {}, e)); @@ -3461,18 +3461,18 @@ public class CompletableFutureTest exten List> fs = new ArrayList<>(); fs.add(incomplete.thenRunAsync(() -> {}, e)); - fs.add(incomplete.thenAcceptAsync((z) -> {}, e)); - fs.add(incomplete.thenApplyAsync((z) -> z, e)); + fs.add(incomplete.thenAcceptAsync(z -> {}, e)); + fs.add(incomplete.thenApplyAsync(z -> z, e)); fs.add(incomplete.thenCombineAsync(incomplete, (x, y) -> x, e)); fs.add(incomplete.thenAcceptBothAsync(incomplete, (x, y) -> {}, e)); fs.add(incomplete.runAfterBothAsync(incomplete, () -> {}, e)); - fs.add(incomplete.applyToEitherAsync(incomplete, (z) -> z, e)); - fs.add(incomplete.acceptEitherAsync(incomplete, (z) -> {}, e)); + fs.add(incomplete.applyToEitherAsync(incomplete, z -> z, e)); + fs.add(incomplete.acceptEitherAsync(incomplete, z -> {}, e)); fs.add(incomplete.runAfterEitherAsync(incomplete, () -> {}, e)); - fs.add(incomplete.thenComposeAsync((z) -> null, e)); + fs.add(incomplete.thenComposeAsync(z -> null, e)); fs.add(incomplete.whenCompleteAsync((z, t) -> {}, e)); fs.add(incomplete.handleAsync((z, t) -> null, e)); @@ -3882,31 +3882,31 @@ public class CompletableFutureTest exten List, CompletableFuture>> funs = new ArrayList<>(); - funs.add((y) -> m.thenRun(y, noopRunnable)); - funs.add((y) -> m.thenAccept(y, noopConsumer)); - funs.add((y) -> m.thenApply(y, incFunction)); - - funs.add((y) -> m.runAfterEither(y, incomplete, noopRunnable)); - funs.add((y) -> m.acceptEither(y, incomplete, noopConsumer)); - funs.add((y) -> m.applyToEither(y, incomplete, incFunction)); - - funs.add((y) -> m.runAfterBoth(y, v42, noopRunnable)); - funs.add((y) -> m.runAfterBoth(v42, y, noopRunnable)); - funs.add((y) -> m.thenAcceptBoth(y, v42, new SubtractAction(m))); - funs.add((y) -> m.thenAcceptBoth(v42, y, new SubtractAction(m))); - funs.add((y) -> m.thenCombine(y, v42, new SubtractFunction(m))); - funs.add((y) -> m.thenCombine(v42, y, new SubtractFunction(m))); - - funs.add((y) -> m.whenComplete(y, (Integer r, Throwable t) -> {})); - - funs.add((y) -> m.thenCompose(y, new CompletableFutureInc(m))); - - funs.add((y) -> CompletableFuture.allOf(y)); - funs.add((y) -> CompletableFuture.allOf(y, v42)); - funs.add((y) -> CompletableFuture.allOf(v42, y)); - funs.add((y) -> CompletableFuture.anyOf(y)); - funs.add((y) -> CompletableFuture.anyOf(y, incomplete)); - funs.add((y) -> CompletableFuture.anyOf(incomplete, y)); + funs.add(y -> m.thenRun(y, noopRunnable)); + funs.add(y -> m.thenAccept(y, noopConsumer)); + funs.add(y -> m.thenApply(y, incFunction)); + + funs.add(y -> m.runAfterEither(y, incomplete, noopRunnable)); + funs.add(y -> m.acceptEither(y, incomplete, noopConsumer)); + funs.add(y -> m.applyToEither(y, incomplete, incFunction)); + + funs.add(y -> m.runAfterBoth(y, v42, noopRunnable)); + funs.add(y -> m.runAfterBoth(v42, y, noopRunnable)); + funs.add(y -> m.thenAcceptBoth(y, v42, new SubtractAction(m))); + funs.add(y -> m.thenAcceptBoth(v42, y, new SubtractAction(m))); + funs.add(y -> m.thenCombine(y, v42, new SubtractFunction(m))); + funs.add(y -> m.thenCombine(v42, y, new SubtractFunction(m))); + + funs.add(y -> m.whenComplete(y, (Integer r, Throwable t) -> {})); + + funs.add(y -> m.thenCompose(y, new CompletableFutureInc(m))); + + funs.add(y -> CompletableFuture.allOf(y)); + funs.add(y -> CompletableFuture.allOf(y, v42)); + funs.add(y -> CompletableFuture.allOf(v42, y)); + funs.add(y -> CompletableFuture.anyOf(y)); + funs.add(y -> CompletableFuture.anyOf(y, incomplete)); + funs.add(y -> CompletableFuture.anyOf(incomplete, y)); for (Function, CompletableFuture> fun : funs) { @@ -3963,12 +3963,12 @@ public class CompletableFutureTest exten public void testMinimalCompletionStage_minimality() { if (!testImplementationDetails) return; Function toSignature = - (method) -> method.getName() + Arrays.toString(method.getParameterTypes()); + method -> method.getName() + Arrays.toString(method.getParameterTypes()); Predicate isNotStatic = - (method) -> (method.getModifiers() & Modifier.STATIC) == 0; + method -> (method.getModifiers() & Modifier.STATIC) == 0; List minimalMethods = Stream.of(Object.class, CompletionStage.class) - .flatMap((klazz) -> Stream.of(klazz.getMethods())) + .flatMap(klazz -> Stream.of(klazz.getMethods())) .filter(isNotStatic) .collect(Collectors.toList()); // Methods from CompletableFuture permitted NOT to throw UOE @@ -3984,7 +3984,7 @@ public class CompletableFutureTest exten .collect(Collectors.toSet()); List allMethods = Stream.of(CompletableFuture.class.getMethods()) .filter(isNotStatic) - .filter((method) -> !permittedMethodSignatures.contains(toSignature.apply(method))) + .filter(method -> !permittedMethodSignatures.contains(toSignature.apply(method))) .collect(Collectors.toList()); List> stages = new ArrayList<>(); @@ -4144,7 +4144,7 @@ public class CompletableFutureTest exten CompletionStage minimal = f.minimalCompletionStage(); CompletableFuture g = new CompletableFuture<>(); if (!createIncomplete) assertTrue(f.complete(v1)); - minimal.thenAccept((x) -> g.complete(x)); + minimal.thenAccept(x -> g.complete(x)); if (createIncomplete) assertTrue(f.complete(v1)); g.join(); checkCompletedNormally(g, v1); @@ -4168,7 +4168,7 @@ public class CompletableFutureTest exten static Function> compose (Function> f, Function> g) { - return (x) -> f.apply(x).thenCompose(g); + return x -> f.apply(x).thenCompose(g); } static void assertZero(CompletableFuture f) { @@ -4248,9 +4248,9 @@ public class CompletableFutureTest exten // Some mutually non-commutative functions Function> triple - = (x) -> Monad.unit(3 * x); + = x -> Monad.unit(3 * x); Function> inc - = (x) -> Monad.unit(x + 1); + = x -> Monad.unit(x + 1); // unit is a right identity: m >>= unit === m Monad.assertFutureEquals(inc.apply(5L).thenCompose(unit), @@ -4262,7 +4262,7 @@ public class CompletableFutureTest exten // associativity: (m >>= f) >>= g === m >>= ( \x -> (f x >>= g) ) Monad.assertFutureEquals( unit.apply(5L).thenCompose(inc).thenCompose(triple), - unit.apply(5L).thenCompose((x) -> inc.apply(x).thenCompose(triple))); + unit.apply(5L).thenCompose(x -> inc.apply(x).thenCompose(triple))); // The case for CompletableFuture as an additive monad is weaker... @@ -4272,7 +4272,7 @@ public class CompletableFutureTest exten // left zero: zero >>= f === zero Monad.assertZero(zero.thenCompose(inc)); // right zero: f >>= (\x -> zero) === zero - Monad.assertZero(inc.apply(5L).thenCompose((x) -> zero)); + Monad.assertZero(inc.apply(5L).thenCompose(x -> zero)); // f plus zero === f Monad.assertFutureEquals(Monad.unit(5L), @@ -4330,8 +4330,8 @@ public class CompletableFutureTest exten final AtomicInteger count = new AtomicInteger(0); for (int i = 0; i < n; i++) { head.thenRun(() -> count.getAndIncrement()); - head.thenAccept((x) -> count.getAndIncrement()); - head.thenApply((x) -> count.getAndIncrement()); + head.thenAccept(x -> count.getAndIncrement()); + head.thenApply(x -> count.getAndIncrement()); head.runAfterBoth(complete, () -> count.getAndIncrement()); head.thenAcceptBoth(complete, (x, y) -> count.getAndIncrement()); @@ -4341,11 +4341,11 @@ public class CompletableFutureTest exten complete.thenCombine(head, (x, y) -> count.getAndIncrement()); head.runAfterEither(new CompletableFuture(), () -> count.getAndIncrement()); - head.acceptEither(new CompletableFuture(), (x) -> count.getAndIncrement()); - head.applyToEither(new CompletableFuture(), (x) -> count.getAndIncrement()); + head.acceptEither(new CompletableFuture(), x -> count.getAndIncrement()); + head.applyToEither(new CompletableFuture(), x -> count.getAndIncrement()); new CompletableFuture().runAfterEither(head, () -> count.getAndIncrement()); - new CompletableFuture().acceptEither(head, (x) -> count.getAndIncrement()); - new CompletableFuture().applyToEither(head, (x) -> count.getAndIncrement()); + new CompletableFuture().acceptEither(head, x -> count.getAndIncrement()); + new CompletableFuture().applyToEither(head, x -> count.getAndIncrement()); } head.complete(null); assertEquals(5 * 3 * n, count.get()); @@ -4362,11 +4362,11 @@ public class CompletableFutureTest exten f.complete(null); f = new CompletableFuture<>(); - f.acceptEither(incomplete, (x) -> {}); + f.acceptEither(incomplete, x -> {}); f.complete(null); f = new CompletableFuture<>(); - f.applyToEither(incomplete, (x) -> x); + f.applyToEither(incomplete, x -> x); f.complete(null); f = new CompletableFuture<>(); @@ -4380,11 +4380,11 @@ public class CompletableFutureTest exten f.complete(null); f = new CompletableFuture<>(); - incomplete.acceptEither(f, (x) -> {}); + incomplete.acceptEither(f, x -> {}); f.complete(null); f = new CompletableFuture<>(); - incomplete.applyToEither(f, (x) -> x); + incomplete.applyToEither(f, x -> x); f.complete(null); f = new CompletableFuture<>();