[concurrency-interest] More Javadoc problems

Doug Lea dl at cs.oswego.edu
Sat Dec 20 13:24:24 EST 2014


On 12/20/2014 10:28 AM, cowwoc wrote:

> "unless" is one sentence away from what it is referring to. I suggest
> changing:
>
>       "If the supplied action itself encounters an exception, then the
> returned stage exceptionally completes with this exception unless this
> stage also completed exceptionally."
>
> to:
>
>       "If the supplied action itself encounters an exception, then the
> returned stage exceptionally completes with this exception unless this
> stage also completed exceptionally (in which case, the returned stage
> exceptionally completes with the original exception)."

Thanks. This should save other people some problems in decoding.
(This will probably take a while to propagate to OpenJDK.)

> I would actually love it for whenComplete() to behave like finally()

It does!

> because if it did it would throw exception2.addSuppressed(exception1)
> instead of exception1. Would it not?

Not. This is only done in try-with-resources.
See the (adjacent) JLS sections:

http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.20.2

http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.20.3

I think that the best we can do here is to echo the standard strong
advice to localize handling of exceptions thrown in exception handlers,
and when this is impossible to use addSuppressed to alert downstream
completions of unrelated exceptions while handling the reported
exceptions. IDEs and tools might be helpful in spreading this advice.

> PS: When is the online Javadoc updated?

The only answer I know is "eventually" :-)

-Doug



More information about the Concurrency-interest mailing list