jsr369-experts@servlet-spec.java.net

[jsr369-experts] Re: Calling onWritePossible "the first time"?

From: Mark Thomas <markt_at_apache.org>
Date: Wed, 20 Jul 2016 21:36:41 +0200

On 20/07/2016 03:41, Greg Wilkins wrote:

<snip/>

> So we cannot have both read and write being called "the first time",
> because we can't do both. Also because other events can intervene, we
> can't even guarantee that the state which scheduled a call still
> persists when the call is actually made. Implementations must always
> use isReady and if they use non container threads they must also use
> some mutual exclusion to prevent events getting in between a call to
> isReady and a subsequent operation.
>
>
> I think we should change the javadoc to read:
>
> onWritePossible:
>
> this method will be invoked by the container after it is possible to
> write data
>
>
> onReadPossible:
>
> this method will be invoked by the container after it is possible to
> read data.

+1

And I'd add something along the lines of your point above:

"The state that triggered the call to on[Read|Write]Possible() may not
still be valid when the call is made. Therefore implementations must
always call isReady() before attempting to perform a [read|write]."

Mark