[concurrency-interest] CompletableFuture.whenComplete survey

joe.bowbeer at gmail.com joe.bowbeer at gmail.com
Mon Dec 21 09:01:15 EST 2015


Given this discussion, I had assumed that the jdk8 documentation left the door open regarding what happened if the whenComplete action itself threw an exception, but the CompletionStage#whenComplete javadoc clearly specifies what happens:





"If the supplied action itself encounters an exception, then the returned stage exceptionally completes with this exception unless this stage also completed exceptionally."





I agree that better documentation about the intended use is needed. I've learned more from this discussion than from the CompletionStage and CompletableFuture javadoc.

On Mon, Dec 21, 2015 at 5:15 AM, Doug Lea <dl at cs.oswego.edu> wrote:

> 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.
> -Doug
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20151221/13998203/attachment.html>


More information about the Concurrency-interest mailing list