Difference between thenAccept and thenApply

I'm reading the document on CompletableFuture and The description for thenAccept() is Returns a new CompletionStage that, when this stage completes normally, is executed with this stage's result as the argument to the supplied action. and for ...
more »

2017-07-18 20:07 (1) Answers

Java CompletableFuture: only first result

After reading this article https://community.oracle.com/docs/DOC-995305 on Oracle site i'm trying to implement the pattern described in "Some Two-to-One Selecting Patterns" paragraph. This last category of patterns also contains two-to-one patterns. ...
more »

2017-04-13 16:04 (2) Answers

Most efficient way to stream on list of Futures

I'm calling an async client method by streaming over a list of objects. The method returns Future. What's the best way to iterate over the list of Futures returned after the call (so as to process those Future which comes first)? Note: The async cl...
more »

2017-04-05 10:04 (1) Answers

CompletableFuture | thenApply vs thenCompose

I can't get my head around the difference between thenApply() and thenCompose(). So, could someone provide a valid use case? From the Java docs: thenApply(Function<? super T,? extends U> fn) Returns a new CompletionStage that, when th...
more »

2017-03-25 17:03 (2) Answers

"Double" composition with CompletableFuture

I'm trying to avoid nesting CompletableFuture when combining 2 independent ones with a BiFunction that returns a third one. Currently, using thenCombine() does not cut it: // What I have public CompletableFuture<CompletableFuture<C>> doS...
more »

2017-02-13 14:02 (2) Answers