[concurrency-interest] CompletableFuture.whenComplete survey
dl at cs.oswego.edu
Mon Dec 21 08:06:10 EST 2015
On 12/19/2015 11:40 AM, Timo Kinnunen wrote:
> there’s too much overlap between the whenComplete(BiConsumer) method and the
> handle(BiFunction) method.
Just as a reminder, the initial intent was that handle() translates
source outcomes, but whenComplete() preserves them.
This leaves open the policy about what to do if the action in
whenComplete itself throws an exception, so cannot preserve the
outcome without losing information. Which is the issue at hand:
in jdk8, a new exception encountered in whenComplete is dropped
if the outcome is already exceptional.
As I've said, regardless of survey results, we should improve
documentation to more strongly advise users to use handle()
instead of whenComplete() when intentionally translating outcomes.
It seems that most users know this already. As far as we know,
no user has ever complained about jdk8 behavior. The issue was
noticed while Chris was exploring an alternative implementation of
CompletionStage, suggesting that we could do better.
More information about the Concurrency-interest