Future.resultNow / exceptionNow

Remi Forax forax at univ-mlv.fr
Sat Nov 20 16:51:57 UTC 2021


----- Original Message -----
> From: "Alex Otenko" <oleksandr.otenko at gmail.com>
> To: "loom-dev" <loom-dev at openjdk.java.net>
> Sent: Samedi 20 Novembre 2021 17:43:47
> Subject: Future.resultNow / exceptionNow

> 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.
> 
> Returning Optional seems a nicer alternative.

Hi Alex, the idea of resultNow()/exceptionNow() is that it should be called when you have the guarantee that isDone is true,
like after a call to StructuredExecutor.join()/joinUntil().

So it should throw a ISE because it means that you have not use resultNow()/exceptionNow() correctly, by example because you have forgotten to do call StructuredExecutor.join() first.

> 
> Alex

regards,
Rémi


More information about the loom-dev mailing list