-
Couldn't load subscription status.
- Fork 38.8k
Closed as not planned
Closed as not planned
Copy link
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently apply
Description
We have some custom observability code added to Web Socket Connection lifecycle.
The following exception happens when we try to call getRemoteAddress() on an erroring-out and closing session.
java.lang.IllegalArgumentException: Object of class [null] must be an instance of class java.net.InetSocketAddress
at org.springframework.util.Assert.instanceCheckFailed(Assert.java:702) ~[spring-core-5.3.25.jar:5.3.25]
at org.springframework.util.Assert.isInstanceOf(Assert.java:602) ~[spring-core-5.3.25.jar:5.3.25]
at org.springframework.util.Assert.isInstanceOf(Assert.java:633) ~[spring-core-5.3.25.jar:5.3.25]
at org.springframework.web.socket.adapter.jetty.JettyWebSocketSession$Jetty10SessionHelper.getRemoteAddress(JettyWebSocketSession.java:351) ~[spring-websocket-5.3.25.jar:5.3.25]
at org.springframework.web.socket.adapter.jetty.JettyWebSocketSession.getRemoteAddress(JettyWebSocketSession.java:153) ~[spring-websocket-5.3.25.jar:5.3.25]
at <our custom handler, that calls session.getRemoteAddress()>
at org.springframework.web.socket.handler.WebSocketHandlerDecorator.handleTransportError(WebSocketHandlerDecorator.java:80) ~[spring-websocket-5.3.25.jar:5.3.25]
at org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.handleTransportError(LoggingWebSocketHandlerDecorator.java:64) ~[spring-websocket-5.3.25.jar:5.3.25]
at org.springframework.web.socket.handler.ExceptionWebSocketHandlerDecorator.handleTransportError(ExceptionWebSocketHandlerDecorator.java:68) ~[spring-websocket-5.3.25.jar:5.3.25]
at org.springframework.web.socket.adapter.jetty.Jetty10WebSocketHandlerAdapter.onWebSocketError(Jetty10WebSocketHandlerAdapter.java:130) ~[spring-websocket-5.3.25.jar:5.3.25]
at org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandler.onError(JettyWebSocketFrameHandler.java:260) ~[websocket-jetty-common-10.0.14.jar:10.0.14]
at org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession.lambda$closeConnection$2(WebSocketCoreSession.java:284) ~[websocket-core-common-10.0.14.jar:10.0.14]
at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1470) ~[jetty-server-10.0.14.jar:10.0.14]
at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1489) ~[jetty-server-10.0.14.jar:10.0.14]
at org.eclipse.jetty.websocket.core.server.internal.AbstractHandshaker$1.handle(AbstractHandshaker.java:212) ~[websocket-core-server-10.0.14.jar:10.0.14]
at org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession.closeConnection(WebSocketCoreSession.java:284) ~[websocket-core-common-10.0.14.jar:10.0.14]
at org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession.onEof(WebSocketCoreSession.java:254) ~[websocket-core-common-10.0.14.jar:10.0.14]
at org.eclipse.jetty.websocket.core.internal.WebSocketConnection.onClose(WebSocketConnection.java:221) ~[websocket-core-common-10.0.14.jar:10.0.14]
at org.eclipse.jetty.io.SelectorManager.connectionClosed(SelectorManager.java:330) ~[jetty-io-10.0.14.jar:10.0.14]
Expected
It's clearly not an intended behavior of getRemoteAddress method to throw on null here, especially taking into account that WebSocketSession#getRemoteAddress is explicitly marked an @Nullable
Environment
Spring 5.3.x and Jetty 10
This doesn't reproduce on Spring 5.2.x and 6+.
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently apply