[concurrency-interest] CompletableFuture.whenComplete survey

Martin Buchholz martinrb at google.com
Sat Dec 19 12:58:32 EST 2015


On Sat, Dec 19, 2015 at 6:15 AM, Doug Lea <dl at cs.oswego.edu> wrote:
> On 12/19/2015 08:40 AM, Joe Bowbeer wrote:

>> 1. That exception1 is not "suppressed" because it has already been
>> delivered
>> to user code.
>
>
> This always holds for a suppressed exception -- some code catches it
> but then does addSuppressed.

Unsurprisingly, I agree with Joe here.  For try-with-resources it is
hard for real user code to directly handle the failure from an
AutoCloseable

try (FileOutputStream s = ...)

The only way I can think of doing that is by creating another
AutoCloseable that wrapped the FileOutputStream, which is cumbersome.
(I guess users would just fall back to sugar-free try/catch/finally)

BUT with whenComplete, the user code has the exception handed to them
directly as an argument - no machinery required.


More information about the Concurrency-interest mailing list