https://issues.apache.org/bugzilla/show_bug.cgi?id=51630

Konstantin Kolinko <knst.koli...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
          Component|Catalina                    |Examples
            Version|7.0.19                      |7.0.22
         Resolution|WORKSFORME                  |

--- Comment #3 from Konstantin Kolinko <knst.koli...@gmail.com> 2011-10-03 
11:10:10 UTC ---
Observing this as well with current trunk@r1178371 (7.0.22) using Nio
connector.
WinXP 32-bit, JDK 6u26.

Steps to reproduce:
1. Configure Tomcat with org.apache.coyote.http11.Http11NioProtocol
I also have logging configured with OneLineFormatter, but that should not
matter.

2. Start it and open in web browser the following page:
http://localhost:8080/examples/async/async0

3. The following exception is in localhost.<date>.log: (not in catalina*.log !)

03-окт-2011 14:35:15.218 SEVERE [http-nio-8080-exec-2]
org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for
servlet [async0] in context with path [/examples] threw exception
[java.lang.RuntimeException: java.lang.IllegalStateException: Calling
[asyncComplete()] is not valid for a request with Async state [DISPATCHED]]
with root cause
 java.lang.IllegalStateException: Calling [asyncComplete()] is not valid for a
request with Async state [DISPATCHED]
    at
org.apache.coyote.AsyncStateMachine.asyncComplete(AsyncStateMachine.java:221)
    at
org.apache.coyote.http11.Http11NioProcessor.actionInternal(Http11NioProcessor.java:476)
    at
org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:807)
    at org.apache.coyote.Request.action(Request.java:344)
    at
org.apache.catalina.core.AsyncContextImpl.complete(AsyncContextImpl.java:89)
    at async.Async0.service(Async0.java:42)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
    at
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
    at
org.apache.catalina.core.AsyncContextImpl$1.run(AsyncContextImpl.java:173)
    at
org.apache.catalina.core.AsyncContextImpl.doInternalDispatch(AsyncContextImpl.java:314)
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at
org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:296)
    at
org.apache.coyote.http11.AbstractHttp11Processor.asyncDispatch(AbstractHttp11Processor.java:1486)
    at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:511)
    at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1554)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

In catalina.<date>.log one can see debug messages from Async0 servlet:
03-окт-2011 14:35:15.218 INFO [http-nio-8080-exec-2] async.Async0.service
Received dispatch, completing on the worker thread.
03-окт-2011 14:35:15.218 INFO [http-nio-8080-exec-2] async.Async0.service After
complete called started:false

What bothers me is that Async0 servlet is not annotated with
@WebServlet(asyncSupported=true) as required by ch.2.3.3.3 of
servlet-3_0-final-spec.pdf.  Page #12 (34/230) there: "It is illegal to call
startAsync if the request is within the scope of a servlet or filter that does
not support asynchronous operations"

The same chapter describes "isAsyncStarted()" saying that it should return
false after a dispatch call. That is what we are observing here.

>From description of "complete()" in the same chapter, it is container's
responsibility to call complete() after service() method exits: "The complete
method can be invoked by the container if
the request is dispatched to a servlet that does not support async processing,
or
the target servlet called by AsyncContext.dispatch does not do a
subsequent call to startAsync. In this case, it is the container's
responsibility
to call complete() as soon as that servlet's service method is exited."


So I think the IllegalStateException is valid here, but the Async0 example
should be fixed by removing the complete() call and annotating the servlet with
@WebServlet(asyncSupported=true).

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to