Hi,

I have a question about ServletOutputStream.setWriteListener.

I have the following scenario:
- Request 1 - in the servlet service method it starts async operation and
starts waiting for a particular notification
- Request 2  - in the servlet service method it starts async operation and
notifies the Request 1 to write to the response
- During this notification Request 1 sets WriteListener. This happens while
we are still in the service method of the servlet for Request 2 i.e. this
happens in the thread that processes Request 2.
- Request 1 starts waiting for onWritePossible but the event is never sent.

So the question is whether it is allowed to set the WriteListener from the
thread that is processing another request?

I can see that when setWriteListener is invoked [1] we add to the
dispatches - NON_BLOCKING_WRITE - this is a result of the DISPATCH_WRITE
action.
But I think that we have to invoke DISPATCH_EXECUTE.

I tried to extract one very simple example [2] that shows the scenario.

What do you think?

Thanks,
Violeta

[1]
https://github.com/apache/tomcat/blob/trunk/java/org/apache/coyote/Response.java#L607
[2] https://github.com/violetagg/test-write-listener

Reply via email to