-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Karsten Sperling opened SPR-14267 and commented
The various send*() methods in org.springframework.web.socket.adapter.jetty.JettyWebSocketSession call getNativeSession().getRemote() each time. If the connection has been closed by the remote end, this will throw a org.eclipse.jetty.websocket.api.WebSocketException.WebSocketException. Expected behaviour would be to receive an IOException instead.
Whether this is a bug in the Jetty API is debatable -- I would certainly consider it somewhat undesirable in the same way as the recently fixed #18710, and it would be nice if the Jetty API aligned with the javax.websocket API where getBasicRemote() / getAsyncRemote() doesn't throw even when the connection has been closed.
If the Jetty RemoteEndpoint has been obtained while the connection is still open, any subsequent call to send*() after the connection has been closed will throw an IOException as expected.
In either case, it would be helpful if this could be worked around in spring-websocket. The easiest approach to fix the specific issue would be to simply call getRemote() once when the connection is established. Another approach would be to catch the Jetty-specific WebSocketException and wrap it in an IOException.
As an aside, is there any particular reason why JettyWebSocketHandlerAdapter is implemented using the annotation-based Jetty websocket API rather than the more straightforward WebSocketListener and related interfaces?
Affects: 4.2.6
Referenced from: commits 3fb58cd