[External] : Re: Future.resultNow / exceptionNow

Ron Pressler ron.pressler at oracle.com
Sun Nov 21 11:32:53 UTC 2021


Perhaps it might be better to have both resultNow and exceptionNow fail in three of the four states.
Some convenience methods could be added to the State enum rather than to Future.

— Ron

On 20 Nov 2021, at 23:10, Alex Otenko <oleksandr.otenko at gmail.com<mailto:oleksandr.otenko at gmail.com>> wrote:

Ok, state...

Looking at State - it seems there are three cases when resultNow will throw. That's probably ok, as there is only one to look out for. But exceptionNow will throw in two cases, which makes the check a little inconvenient.

I still think it would be nice to either not throw at all, or have a isCompletedNormally/Exceptionally.

Alex

On Sat, 20 Nov 2021, 20:51 Ron Pressler, <ron.pressler at oracle.com<mailto:ron.pressler at oracle.com>> wrote:

> On 20 Nov 2021, at 16:43, Alex Otenko <oleksandr.otenko at gmail.com<mailto:oleksandr.otenko at gmail.com>> wrote:
>
> Is there a strong opinion about Future.resultNow and exceptionNow throwing
> IllegalStateException? It seems there will likely be boilerplate
> try-catching, as there is no safe way to inquire in what way the Future is
> isDone.


See the new Future.state(). But in many/most cases you would’t even need it.



More information about the loom-dev mailing list