2013/5/28 Konstantin Kolinko wrote:
>
>
> I think that your patch is wrong.
>
> Looking at how ActionCode.ASYNC_DISPATCH is handled in different
> connector implementations in Tomcat 7, the code is like the following:
>
>             if (asyncStateMachine.asyncDispatch()) {
>                 ((AprEndpoint)endpoint).processSocketAsync(this.socket,
>                         SocketStatus.OPEN);
>             }
>
> In your example dispatching does not happen immediately as
> asyncDispatch() call returns "false" and asyncStateMachine state
> changes to AsyncState.MUST_DISPATCH.  Thus your patch works.
>
> But, there is a case when the call returns "true" and dispatching
> happens immediately. Such dispatching will be broken.

Thanks for pointing this.

>
> BTW, I wonder if the following can be an alternative:
>
> if (this.dispatch != null) throw new IllegalStateException("..");

Unfortunately this will break another scenario:

Servlet1 does dispatch to Servlet2

AsyncContext asyncContext = request.startAsync(request, response);
asyncContext .dispatch("/Servlet2");

Servlet2 does dispatch to resourceA

AsyncContext asyncContext = request.startAsync(request, response);
asyncContext .dispatch("/Servlet2");         <==== here we still do not
have invocation to AsyncContextImpl.recycle and AsyncContextImpl.dispatch
field is not null


So if we introduce a null check we will break double dispatch scenario.

The solution might be to separate the check for state and the actual action
invocation.
Wdyt?

Violeta

>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>

Reply via email to