jsr369-experts@servlet-spec.java.net

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

From: Mark Thomas <markt_at_apache.org>
Date: Thu, 7 Apr 2016 21:29:35 +0100

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