Код: Выделить всё
@Test
void promiseTestCompose2() throws Exception {
CompletableFuture future1 = CompletableFuture
.supplyAsync(this::slowInit)
.thenApply(this::slowIncrement);
CompletableFuture thenCompose = future1
.thenCompose(value -> CompletableFuture.supplyAsync(() -> value))
.thenApply(this::slowIncrement);
int result = thenCompose.get();
assertEquals(result, 3);
}
Код: Выделить всё
CompletableFuture thenCompose = future1
.thenCompose(value -> CompletableFuture.supplyAsync(() -> value))
.thenApply(this::slowIncrement);
Код: Выделить всё
CompletableFuture thenCompose = future1.thenApply(this::slowIncrement);
Поэтому мой вопрос заключается в том, .thenCompose(value -> CompletableFuture.supplyAsync(() -> value))< /code> здесь действительно лишний или я что-то упустил?
Мне хотелось бы получить объяснение, могу ли я удалить thenCompose(), если он не изменяет входящее значение .
Подробнее здесь: https://stackoverflow.com/questions/785 ... y-the-inco