using thenCombine instead of join to merge to CompletableFuture (#31304)

This commit is contained in:
uazw 2022-04-01 15:58:20 +08:00 committed by GitHub
parent 060ffc7b71
commit b5c29e05c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -841,14 +841,7 @@ public class ActorDocTest extends AbstractJavaTest {
// using timeout from above // using timeout from above
CompletableFuture<Object> future2 = ask(actorB, "another request", t).toCompletableFuture(); CompletableFuture<Object> future2 = ask(actorB, "another request", t).toCompletableFuture();
CompletableFuture<Result> transformed = CompletableFuture<Result> transformed = future1.thenCombine(future2, (x, s) -> new Result((String) x, (String) s));
CompletableFuture.allOf(future1, future2)
.thenApply(
v -> {
String x = (String) future1.join();
String s = (String) future2.join();
return new Result(x, s);
});
pipe(transformed, system.dispatcher()).to(actorC); pipe(transformed, system.dispatcher()).to(actorC);
// #ask-pipe // #ask-pipe