Bug 62569 - Async servlet setReadListener does not work if post request data arrives much later than headers
Summary: Async servlet setReadListener does not work if post request data arrives much...
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Servlet (show other bugs)
Version: 9.0.10
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2018-07-25 18:55 UTC by Dapeng Zhang
Modified: 2018-08-07 17:09 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Dapeng Zhang 2018-07-25 18:55:24 UTC
In async mode, servlet sets a ReadListener, and invokes onDataAvailable callbacks.
If a client first sends out a POST request headers, then 2 seconds later sends out the payload. The ReadListener callbacks will never be invoked, and the client never receives a response. Glassfish 5.0 does not have this issue. This may not be a serious problem for HTTP/1.1 and servlet 3.1, but it is a problem for HTTP/2 and servlet 4.0 because HTTP/2 is ful-duplex.

See the servlet code snippet in the Java EE tutorial example:

Client side command:

telnet localhost 8080

POST /asyncioservlet HTTP/1.1
Host: localhost
Content-Type: application/json
Transfer-Encoding: chunked

Comment 1 Mark Thomas 2018-08-07 15:48:35 UTC
This works for me. Note that the example is buggy - it does not handle the "-1" value returned by read when EOF is reached.
Comment 2 Dapeng Zhang 2018-08-07 17:09:05 UTC
My mistake. This does work. Sorry about that. But I do have some issues that ReadListener and WriteListener callbacks never get called when using http/2 (https://github.com/grpc/grpc-java/pull/4738). Will update once I find a easy way to reproduce it.