Loom Evades Exception Handling

Alan Bateman Alan.Bateman at oracle.com
Fri Nov 26 16:16:54 UTC 2021


On 26/11/2021 15:51, Eric Kolotyluk wrote:
> :
>
> From Structured Concurrency 
> <https://bugs.openjdk.java.net/browse/JDK-8277129>, the example
> |<T> List<T> runAll(List<Callable<T>> tasks) throws Throwable { try 
> (var s = StructuredExecutor.open()) { var handler = new 
> StructuredExecutor.ShutdownOnFailure(); List<Future<T>> futures = 
> tasks.map(t -> s.fork(t, handler)).toList(); s.join(); 
> handler.throwIfFailed(e -> e); // propagate exception as-is return 
> futures.map(Future::resultNow).toList(); } } |
> Is sort of what I want to do, but as far as I can tell, that example 
> won't compile because "|tasks.map()|" is not allowed, you need to use 
> " |tasks.stream.map()|". If I could apply the usual monadic operations 
> to Java collections, in a non-lazy way like Kotlin and Scala, I would 
> not have fallen into this trap, but it's unrealistic to believe that 
> Java collections will change to make me happy.
>
> Note: someone should correct the examples on this page...
>
Thanks, this one is fixed now.

-Alan


More information about the loom-dev mailing list