https://bz.apache.org/bugzilla/show_bug.cgi?id=67293
--- Comment #2 from outsider...@gmail.com ---
Indeed, error description was confusing.
I made additional analyze and now error description should be clear:
https://github.com/apache/tomcat/blob/10.1.13/java/org/apache/tomcat/websocket/WsSession.java#L614
614public void onClose(CloseReason closeReason) {
615if (state.compareAndSet(State.OPEN, State.CLOSING)) {
616// Standard close.
617
618// Flush any batched messages not yet sent.
619try {
620wsRemoteEndpoint.setBatchingAllowed(false);
621} catch (Throwable t) {
622ExceptionUtils.handleThrowable(t);
623log.warn(sm.getString("wsSession.flushFailOnClose"), t);
624fireEndpointOnError(t);
625}
626
627// Send the close message response to the remote endpoint.
628sendCloseMessage(closeReason);
629fireEndpointOnClose(closeReason);
630
631// Mark the session as fully closed.
632state.set(State.CLOSED);
Before line 632 session has state "OPEN"
Line 628 through stack
writeMessagePart:469, WsRemoteEndpointImplBase (org.apache.tomcat.websocket)
sendMessageBlock:308, WsRemoteEndpointImplBase (org.apache.tomcat.websocket)
sendMessageBlock:257, WsRemoteEndpointImplBase (org.apache.tomcat.websocket)
sendCloseMessage:718, WsSession (org.apache.tomcat.websocket)
onClose:628, WsSession (org.apache.tomcat.websocket)
makes
org.apache.tomcat.websocket.WsRemoteEndpointImplBase#closed = true
What happens when someone attempt so send message through websocket between
line 629 and 632, when websocket wsSession.isOpen = true and wsSession.state =
CLOSING? Control goes to
org.apache.tomcat.websocket.WsRemoteEndpointImplBase#writeMessagePart:
void writeMessagePart(MessagePart mp) {
if (closed) {
throw new
IllegalStateException(sm.getString("wsRemoteEndpoint.closed"));
so, if someone attempt so send message between 628 and 631, he get:
IllegalStateException.
And should: IOException
Javadoc for jakarta.websocket.RemoteEndpoint.Basic#sendText(java.lang.String)
clearly states that send text may throw
IllegalArgumentException – if text is null.
IOException – if an I/O error occurs during the sending of the message.
No IllegalStateException
--
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