On 20/10/2016 14:08, Violeta Georgieva wrote: > 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?
Yes, but we don't handle that very well. That looks like a bug to me. > 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. Can you turn that into a unit test for the AsyncContext? Mark > > 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 > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org