https://bz.apache.org/bugzilla/show_bug.cgi?id=65001

            Bug ID: 65001
           Summary: HTTPNIO non-blocking IO servlet 3.1 API may fail to
                    alert webapp that a request is complete
           Product: Tomcat 9
           Version: 9.0.41
          Hardware: PC
                OS: Mac OS X 10.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: frraj...@cisco.com
  Target Milestone: -----

Created attachment 37624
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=37624&action=edit
Test servlet

Under certain IO error conditions, tomcat will fail to alert that an
asynchronous request is completed and destroyed.
Both the AsyncListener's onComplete method and ServletRequestListener's
requestDestroyed method are not called.
This may cause a webapp to believe that a request is still valid while tomcat
has already recycled the objects.

I was able to reproduce this issue using a WriteListener (non-blocking IO
servlet API 3.1) with the httpnio connector on the latest tomcat release
(9.0.41).
This appears to be caused when an IOException is raised while attempting to
write to the ServletOutputChannel during the WriteListener's onWritePossible
callback.

It also seems possible to trigger this issue by manually throwing an exception
in the onWritePossible callback.

The following exception can also be seen in the logs:
java.lang.IllegalStateException: Calling [asyncPostProcess()] is not valid for
a request with Async state [ERROR]

I've attached a test servlet that demonstrates this issue.
To simulate IO errors, an http request is aborted before the full response body
is read. The servlet then records various async callbacks it receives and it
can be seen that some callbacks are not always called, i.e. the AsyncListener's
onComplete callback and ServletRequestListener's requestDestroyed callback.
The servlet compares synchronous requests, asynchronous requests, and
asynchronous requests with non-blocking IO.

-- 
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