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

            Bug ID: 67293
           Summary: WsRemoteEndpointImplBase throws IllegalStateException:
                    WebSocket session has been closed
           Product: Tomcat 10
           Version: 10.1.11
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: WebSocket
          Assignee: dev@tomcat.apache.org
          Reporter: outsider...@gmail.com
  Target Milestone: ------

My client, java.net.http.WebSocket.Listener, is 
public onText(WebSocket webSocket,...) { webSocket.abort()

My server (Spring Boot) is

WebSocketSession session;
try {
  session.sendText(...)
} catch (IllegalStateException e) {
  logger.error("session.isOpen == {}", session.isOpen(), e);

And output is:
session.isOpen ==  true
java.lang.IllegalStateException: Message will not be sent because the WebSocket
session has been closed
        at
org.apache.tomcat.websocket.WsRemoteEndpointImplBase.writeMessagePart(WsRemoteEndpointImplBase.java:450)

Where is a bug?

First, it is strange that however session is still open, I got exception that
session is closed. But I can accept than synchronization may be delayed

Second, I browsed a Javadoc and I found

https://docs.oracle.com/en/java/javase/17/docs/api/java.net.http/java/net/http/WebSocket.html#sendText(java.lang.CharSequence,boolean)

"(...)A CompletableFuture returned from this method can complete exceptionally
with:

IllegalStateException - if there is a pending text or binary send operation or
if the previous binary data does not complete the message
IOException - if an I/O error occurs, or if the output is closed (...)"

Then second problem, a real bug, is that when session is closed, IOexception
should be thrown, not 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

Reply via email to