Description
Tong Chen opened SPR-13326 and commented
If for any reason such as some message parsing failed, StompSubProtocolHandler.sendErrorMessage is called and it ultimately calling StandardWebSocketSession.sendTextMessage to send the error msg back to client.
But from that method call I am getting exception:
"The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method".
It looks like a race condition because when it is trying to use the native session to send msg back, the native session is also used by other normal messages.
Adding the following work around seems to fixed the problem.
@Override
protected void sendTextMessage(TextMessage message) throws IOException {
Session nativeSession = getNativeSession();
synchronized (nativeSession) {
nativeSession.getBasicRemote().sendText(message.getPayload(), message.isLast());
}
}
The message calling flow is quite complicated so I may have missed something obvious please let me know if my observation is flawed.
Issue Links:
- Lock acquired on object responseLock in method sendMessageInternal of class AbstractHttpSockJsSession is not released in some error condition resulting in deadlock [SPR-13449] #18029 Lock acquired on object responseLock in method sendMessageInternal of class AbstractHttpSockJsSession is not released in some error condition resulting in deadlock
Referenced from: commits 33f9ead, 7defbfc
Backported to: 4.1.8