jsr340-experts@servlet-spec.java.net

[jsr340-experts] Re: NIO writes and flush()

From: Mark Thomas <markt_at_apache.org>
Date: Tue, 15 Jan 2013 10:53:34 +0000

On 15/01/2013 10:38, Rémy Maucherat wrote:
> On 01/15/2013 11:31 AM, Mark Thomas wrote:
>> While working on the WebSocket implementation (that requires some writes
>> to be blocking and some non-blocking) I was thinking about the expected
>> behaviour of flush().
>>
>> If I have a ServletOutputStream that is in non-blocking mode and
>> isReady() currently returns false (i.e. there was a previous write that
>> has not been fully written yet) does a call to flush() block until all
>> that data has been written?
>>
>> My reading of the Javadoc is that flush() will block in these
>> circumstances. If this is correct, it might be useful to add this
>> clarification to the Javadoc. If this is wrong, then some clarification
>> is certainly called for.

> If I remember correctly, "smart" blocking was not included,
It wasn't.

> so I don't think flush() is supposed to be blocking.
OK.

> So if isReady() has just
> returned false, then it would mean you should wait for the write
> listener call to do the flush().

But what would be the point of calling flush() at that point?

And if you don't wait should an ISE be thrown if flush() is called?

Mark