I think we need to clarify when onAllDataRead should be called.
My understanding is that once isReady() has returned false, a callback is
scheduled:
- If the IO that arrives is data, then onDataAvailable() is called.
- If the IO that arrives is EOF, then onAllDataRead() is called.
But it is possible for the code within onDataAvailable to read, call
isReady() and get a true result and then read -1 for the EOF. In that
case, should onAllDataRead() be called? If so should it wait until the
call to onDataAvailable() has returned?
I can see it two ways:
Either we have a callback paradigm that is triggered by isReady()==false
and that once that occurs there should be one and only one callback to
either onDataAvailable or to onAllDataRead()
OR
onAllDataRead() is a separate callback paradigm to the onDataAvailable and
will be called regardless once EOF is received.
I think the former is simpler to implement, but might cause surprises for
application developers who expect it always to be called.
The problem with the later is that it means that an onAllDataRead()
callback can come even if isReady()!=false. This breaks the fundamental
callback paradigm that a callback will only occur if isReady() has called
false.
thoughts?
As a secondary question, if EOF has arrived, but neither -1 has been read
or onAllDataRead() called, should isFinished() return true?
cheers
--
Greg Wilkins <gregw_at_intalio.com> @ Webtide - *an Intalio subsidiary*
http://eclipse.org/jetty HTTP, SPDY, Websocket server and client that scales
http://www.webtide.com advice and support for jetty and cometd.