jsr340-experts@servlet-spec.java.net

[jsr340-experts] Re: SERVLET_SPEC-17: Clarify required behaviour when an Async listener throws an exception

From: Shing Wai Chan <shing.wai.chan_at_oracle.com>
Date: Thu, 09 Aug 2012 17:55:23 -0700

Since user code and the listener are in a different thread, so there is
nothing to do except logging the exception
for all the methods in AsyncListener.

Shing Wai Chan

On 12/17/11 1:29 PM, Mark Thomas wrote:
> On 17/12/2011 03:58, Alex Rojkov wrote:
>>> I am looking at http://java.net/jira/browse/SERVLET_SPEC-17 I would
>>> like to put the request in error state when there is an exception
>>> in AsyncListener.
>> I think the bug description is a bit sketchy in detail on what the
>> 'error state' would mean.
>>
>> Also, the listener's methods invocation contexts are different.
>> onStart will be invoked from a thread dedicated to serving the
>> request, so the user's code should handle the exceptions arising from
>> onStart() calls.
> But what happens to the AsyncContext? It will have already been created
> since it has to be accessible via AsyncEvent.getAsyncContext().
>
> My preference is to handle this the same was as errors during the
> dispatch process.
>
>> onComplete, onError and onTimeout are different.
>>
>> Exceptions in onError should result in freeing the container
>> resources, closing the connection without flushing()
> +1
>
>> -onTimeout – the same.
> My preference is the same as for onStart()
>
>> -onComplete - closes the Response, so there is nothing to do except
>> logging the exception.
> +1
>
> Mark