jsr369-experts@servlet-spec.java.net

[jsr369-experts] Re: isFinished() and onAllDataRead() clarifications

From: Mark Thomas <markt_at_apache.org>
Date: Thu, 12 Feb 2015 12:55:49 +0000

On 06/02/2015 22:08, Edward Burns wrote:

<snip/>

> GW> As a secondary question, if EOF has arrived, but neither -1 has been read
> GW> or onAllDataRead() called, should isFinished() return true?
>
> SD> I don't think it should return true until this notification has been
> SD> delivered to the user. Otherwise some layer of code could check this
> SD> flag and take some action based on the isFinished flag, however the
> SD> read listener may not have been notified yet. It also seems counter
> SD> intuitive that callbacks could still be pending when isFinished()
> SD> returns true.
>
>>>>>> On Wed, 7 Jan 2015 17:39:49 -0800, Wenbo Zhu <wenboz_at_google.com> said:
>
> WZ> I would expect all the above behavior too.
>
> MT> Tomcat doesn't do this currently. We actually use the return value of
> MT> isFinished() to check if onAllDataRead() should be called. However, I've
> MT> no objection to clarifying the behaviour of isFinished() so it returns
> MT> false until onAllDataRead() has completed.
>
> The existing spec for isFinished() is:
>
> Spec> isFinished()
>
> Spec> Returns true when all data from the stream has been read else it
> Spec> returns false.
>
> Mark, are you suggesting we should amend this text to be something
> similar to the following?
>
> ProposedSpec> Returns true when all data from the stream has been else
> ProposedSpec> it returns false. If called before onAllDataRead() has
> ProposedSpec> returned to the container, it will also return false.

Yes. I'd suggest something like:

Returns true when all data from the stream has been read and the
onAllDataRead() call-back has returned to the container. Otherwise it
returns false.

Mark