tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yann Simon <>
Subject Re: Tomcat 8.0.0-RC5: asynchron IO and back pressure with ReadListener
Date Thu, 30 Jan 2014 16:51:17 GMT
2014-01-30 Rémy Maucherat <>:
> 2014-01-30 Yann Simon <>:
>> Hi,
>> I wrote a sample app to demonstrate the problem:
>> You can generate an exploded war with maven: mvn war:exploded
>> I deployed the application in tomcat 8.0.0-RC10.
>> The 2 upload form does work.
>> The 1st upload form uses a new thread in , and that does not work.
>> The "onDataAvailable" is called only one time.
>> With jetty, it does work (mvn jetty:run)
>> I hope this can help.
> You must read data until the ready flag flips, and you must do it in the
> onDataAvailable invocation (= synchronously). Asynchronous reads is not the
> threading and sync model that was chosen by the specification, so you
> should simply not do that. I doubt it will reliably work in any container
> since it is almost certain you can run in thread safety issues.
> Rémy

Thx for the explanation.
What is the part of the specification that is saying that
onDataAvailbale must be consumed synchronously?
Is it the last sentence "The Servlet container must access methods in
ReadListener in a thread safe manner." from:

"The ReadListener provides the following callback methods for non blocking IO -
■ ReadListener
■ onDataAvailable() . The onDataAvailable method is invoked on the
ReadListener when data is available to read from the incoming request
stream. The container will invoke the method the first time when data is
available to read. The container will subsequently invoke the onDataAvailable
method if and only if isReady method on ServletInputStream , described
below, returns false .
■ onAllDataRead() . The onAllDataRead method is invoked when you have
finished reading all the data for the ServletRequest for which the listener was
■ onError(Throwable t) . The onError method is invoked if there is any error or
exception that occurs while processing the request.
The Servlet container must access methods in ReadListener in a thread
safe manner."

It means we cannot write real asynchronous reactive applications with
servlet 3.1... disappointing.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message