jsr369-experts@servlet-spec.java.net

[jsr369-experts] Callback Clarifications

From: Edward Burns <edward.burns_at_oracle.com>
Date: Fri, 6 Feb 2015 14:44:45 -0800

>>>>> On Fri, 6 Feb 2015 09:26:51 +1100, Greg Wilkins <gregw_at_intalio.com> said:

GW> So again, here is the list of behaviours that I would like to javadoc if
GW> there are no objections:

GW> - onAllDataRead will always be called once and only once when EOF stream
GW> is reached in the input stream (with the exception for completion - see
GW> below).
GW> - The call to onAllDataRead will NOT be concurrent with any other
GW> callbacks associated with the stream (onDataAvailable, onWritePossible,
GW> service etc.). onAllDataRead will only be called once the prior callback
GW> returns.
GW> - It is possible for -1 to be read from a stream during such a callback
GW> to onDataAvailable.
GW> - It is possible for onAllDataRead to be called directly without -1
GW> being read during a call to onDataAvailable.
GW> - If isReady() returns false, then a callback to onDataAvailable() will
GW> be scheduled for when a read can proceed.
GW> - If the stream is at EOF, then isReady() will return true as -1 can be
GW> read.
GW> - isFinished() will return false until such time as EOF has been
GW> communicated to the application ether by reading -1 or by calling
GW> onAllDataRead()
GW> - If the AsyncContext.complete() method is called, or a Servlet.service
GW> ASYNC dispatch returns without another startAsync, then the
GW> request/response lifecycle is completed and no further callbacks
GW> (onDataAvailable, onAllDataRead, onWritePossible, service, filter) will be
GW> dispatched for that request/response.


GW> Currently our jetty-9.2 release does not act in this way, but our 9.3
GW> snapshot has been made to do so. The result is that it is a bit more
GW> forgiving of user code - ie I think it is harder to write fragile code with
GW> these assumptions. The reason being is that you can choose your EOF
GW> abstraction (onAddDataRead or read -1) you wish to act on and you are
GW> guaranteed of seeing that. Without these assumptions, it is possible for
GW> these EOF signals to be skipped in some circumstances.

These seem reasonable to me, but I'll defer to Shing-wai on these.

Ed

-- 
| edward.burns_at_oracle.com | office: +1 407 458 0017
| 21 days til DevNexus 2015
| 31 days til JavaLand 2015
| 41 days til CONFESS 2015