https://bz.apache.org/bugzilla/show_bug.cgi?id=66676
Bug ID: 66676 Summary: WebSocket session complains about closed state when calling close() Product: Tomcat 10 Version: 10.1.8 Hardware: All OS: All Status: NEW Severity: normal Priority: P2 Component: WebSocket Assignee: dev@tomcat.apache.org Reporter: magicb...@gmx.de Target Milestone: ------ Hey, I've found a bug with the following stacktrace: java.lang.IllegalStateException: The WebSocket session [210b] has been closed and no method (apart from close()) may be called on a closed session at org.apache.tomcat.websocket.WsSession.checkState(WsSession.java:974) at org.apache.tomcat.websocket.WsSession.getUserPrincipal(WsSession.java:862) at org.apache.tomcat.websocket.server.WsServerContainer.unregisterSession(WsServerContainer.java:350) at org.apache.tomcat.websocket.WsSession.sendCloseMessage(WsSession.java:730) at org.apache.tomcat.websocket.WsSession.doClose(WsSession.java:597) at org.apache.tomcat.websocket.WsSession.doClose(WsSession.java:554) at org.apache.tomcat.websocket.WsSession.close(WsSession.java:542) >From the message of the exception it is mentioned that it is valid to call close anytime, so I would not expect this exception. What happens here is, that sending the close message fails, so the WebSocket session gets closed in the "sendCloseMessage" method. Later on in the same method the "unregisterSession" is called which is trying to get the userPrincipal, but as the session was just closed this fails and you end up with this exception. I would either expect that either the "apart from close()" is removed from the message, or the call fails with the original IOException, but not that the "unregistering" fails and by that overruling the IOException from sending the closure and showing a rather confusing message. Let me know if you've any questions. -- 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