[cdi-dev] FireAsyncException question

Martin Kouba mkouba at redhat.com
Mon Jul 13 07:03:29 EDT 2015

Hi all,

the CDI 2.0 EDR1, "10.5.1. Handling multiple exceptions thrown during an 
asynchronous event" currently states:

"If an event is asynchronous, and an exception is thrown by any of its 
notified observers, the CompletionStage returned by fireAsync will 
complete exceptionally with FireAsyncException exception."

And there's also an example of handle() method with lambda which gets 
FireAsyncException passed as an param. This looks good from the user 
point of view.

However, what should happen if I use e.g. thenAccept() method? The 
CompletionStage API is clear:
"Two method forms support processing whether the triggering... In all 
other cases, if a stage's computation terminates abruptly with an 
(unchecked) exception or error, then all dependent stages requiring its 
completion complete exceptionally as well, with a CompletionException 
holding the exception as its cause...". In other words, 
myEvent.fireAsync(...).thenAccept(...).exceptionally(...) should receive 
CompletionException and not FireAsyncException.

This seems a bit inconsistent to me. Am I missing something?

Martin Kouba
Software Engineer
Red Hat, Czech Republic

More information about the cdi-dev mailing list