users@servlet-spec.java.net

[servlet-spec users] Re: Question about ServletOutputStream.setWriteListener

From: Mark Thomas <markt_at_apache.org>
Date: Mon, 31 Oct 2016 14:57:06 +0000

On 27/10/2016 14:32, violetagg_at_abv.bg wrote:
> Hi,
>
> I would like to ask for a clarification about
> ServletOutputStream.setWriteListener.
> In the specification it is not clear when it is allowed to invoke this
> method.
> Should the application go to a non blocking mode right after
> AsyncContect.startAsync while in the container thread or that call can
> be delayed and made from a different thread.

Generally that is what I'd expect to happen but I'm not aware of any
requirements that it has to.

> In Tomcat we allowed a delayed call to this method however we have
> edge use cases [1] and [2] when this causes problems.

[1] looks odd. The OP needs to provide a lot more information (like what
locks are being held) but it looks more like misuse of the API at this
point.

[2] is an implementation issue for Tomcat.

A lot of the implementation issues would be simplified it the spec made
clear that the user must *always* call isReady() before attempting a
read/write even as a result of an onDataAvailable()/onWritePossible()
call. Greg has articulated why this is necessary elsewhere.

Mark


> The same question applies also for ServletInputStream.setReadListener.
>
> Thanks in advance,
> Violeta Georgieva
>
> [1] http://marc.info/?t=147756348200005&r=1&w=2
> [2] http://marc.info/?t=147696900800002&r=1&w=2
>