https://bz.apache.org/bugzilla/show_bug.cgi?id=58624

--- Comment #2 from Barry Coughlan <b.coughl...@gmail.com> ---
Sorry for all the noise.

If I understand correctly, the flow of sending messages goes like this:

WsRemoteEndpointImplBase.startMessage -> messaged dispatched to
WsServerContainer.executor -> calls WsRemoteEndpointImplBase.endMessage on
completion (via EndMessageHandler).

I'm wondering if there could be an exception in the executor callback. For
example, there are some exceptions thrown in writeMessagePart (called by
endMessage). If an exception was thrown there it would be thrown all the way up
to the executor and not logged. Am I correct in saying that exceptions in
executor tasks would not produce exceptions in the Tomcat logs?
ThreadPoolExecutor doesn't log them to the console by
(http://stackoverflow.com/q/2248131/281469)


My current working theory for what's happening is as follows: 
- Server starts sending a message
- The client closes the connection before the executor finishes the message,
which causes WsRemoteEndpointImplBase.closed to be set to true.
- Server finishes sending the message, calls endMessage, which calls
writeMessagePart which throws an IllegalStateException because closed=true.
- Because of the exception the future never completes and the exception doesn't
get logged.

At first I thought the synchronized (messagePartLock) block would protect
against this. However it can still occur:
- The executor task finishes and endMessage() reaches the end of the
synchronized block (but before calling writeMessagePart).
- The client close enters and exits the synchronized block in startMessage().
Calls writeMessagePart(), sets closed=true.
- The executor task calls writeMessagePart().

If this is a race condition it is a very rare one - it occurred once in sending
~5 million messages during a soak test.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to