Bug 57481

Summary: IllegalStateException for nonblocking/numberwriter example with BIO connector
Product: Tomcat 8 Reporter: Konstantin Kolinko <knst.kolinko>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: minor    
Priority: P2    
Version: 8.0.17   
Target Milestone: ----   
Hardware: PC   
OS: All   

Description Konstantin Kolinko 2015-01-22 08:12:35 UTC
Steps to reproduce:
1. Configure Tomcat 8.0.17 to use BIO implementation of HTTP connector,
    <Connector port="8081" address="127.0.0.1"
               protocol="org.apache.coyote.http11.Http11Protocol"
               connectionTimeout="20000"
               redirectPort="8443" />

2. Start Tomcat

3. Access
http://localhost:8081/examples/servlets/nonblocking/numberwriter

4. Result:
The page is displayed successfully (as expected),
but at the same time an IllegalStateException is logged to the console and into catalina.2015-01-22.log file (an unexpected):

[[[
22-Jan-2015 11:02:03.089 SEVERE [http-bio-127.0.0.1-8081-exec-10] org.apache.catalina.connector.CoyoteAdapter.asyncDispatch Exception while processing an asynchronous request
 java.lang.IllegalStateException: Calling [asyncComplete()] is not valid for a request with Async state [DISPATCHED]
	at org.apache.coyote.AsyncStateMachine.asyncComplete(AsyncStateMachine.java:270)
	at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:848)
	at org.apache.coyote.Request.action(Request.java:377)
	at org.apache.catalina.core.AsyncContextImpl.complete(AsyncContextImpl.java:86)
	at nonblocking.NumberWriter$NumberWriterListener.onError(NumberWriter.java:145)
	at org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:304)
	at org.apache.coyote.http11.AbstractHttp11Processor.asyncDispatch(AbstractHttp11Processor.java:1696)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:650)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:147)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:279)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
]]]

The NIO and APR connectors are working OK.
Comment 1 Mark Thomas 2015-01-22 14:46:58 UTC
Fixed in 8.0.x for 8.0.18 onwards. Confirmed this only affects BIO on 8.0.x.