jsr369-experts@servlet-spec.java.net

[jsr369-experts] Re: [servlet-spec users] Re: Re: Re: Re: Clarify onAllDataRead ?

From: Shing Wai Chan <shing.wai.chan_at_oracle.com>
Date: Wed, 7 Dec 2016 17:57:35 -0800

GlassFish and WebLogic are implemented in the former way.

Shing Wai Chan

> On Apr 7, 2016, at 1:29 PM, Mark Thomas <markt_at_apache.org> wrote:
>
> On 06/04/2016 23:48, Greg Wilkins wrote:
>>
>> This conversation was left hanging last year. So I'd just like to
>> confirm if we all agree on the interpretation summarized in the last post.
>>
>> Specifically I'd like to confirm the interpretation of what should
>> happen when an EOF arrives while a thread is already dispatched within
>> onDataAvailable reading previous data.
>>
>> The code will be written in the pattern:
>>
>> while(in.isReady())
>> {
>>
>> int b = in.read();
>>
>> if (b<0)
>>
>> break;
>>
>> // handle b;
>>
>> }
>>
>>
>> Eventually when the EOF arrives, the isReady() call will still return
>> true (can't return false as that implies that onDataAvailable will be
>> called again and we are already here). The read() will then return -1
>> and the loop will exit and the method will return. Once the method has
>> returned the onAllDataRead() method will be called.
>>
>> The alternate interpretation (that some users are asking for) is that
>> the code is written in the form:
>>
>> while(in.isReady())
>> {
>>
>> int b = in.read();
>>
>> // handle b;
>>
>> }
>>
>>
>> Eventually when the EOF arrives, the isReady() call will return false
>> (we probably need to update javadoc to indicate that onDataAvailable not
>> be called after this false ). The loop will exit and the method will
>> return. Once the method has returned the onAllDataRead() method will be
>> called. In this interpretation -1 is never read.
>>
>>
>> Jetty currently is implementing the former interpretation.
>
> Tomcat also implements the former interpretation and I don't see a good
> reason to change that.
>
> Mark
>