jsr340-experts@servlet-spec.java.net

[jsr340-experts] Behavior of Async listener while throw exception

From: Shing Wai Chan <shing.wai.chan_at_oracle.com>
Date: Tue, 04 Dec 2012 13:34:22 -0800

In previous discussion, we discuss the behavior of AsyncListener when
there is an exception while calling onCompleted.
With previous discussion and
http://java.net/jira/browse/SERVLET_SPEC-17, there are three possibilities:
a) log an exception and continue call subsequent listeners
b) call onError
c) the request is in an error state

The javadoc of AsyncListener#onCompleted says:
     Notifies this AsyncListener that an asynchronous operation has been
completed.

I have also compared with the CompletionHandler in JDK 7.
An exception is log in their case.

(a) seems to be a better choice in this case.

I have took a look at implementation in Tomcat and GlassFish and notice
that the exception for
AsyncListener#onStartAsync is propagated back to the caller of
AsyncContext#startAsync.
Servlet 3.0 is spec does "not" mention this.
If we have (a) above, an exception will log in this case and will "not"
propagated back to the caller.

In this case, I would like to confirm that there will be no issue in
choosing (a).
Please let me know if there is any concern.
Thanks.
      Shing Wai Chan