Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JettyWebSocketSession.getRemoteAddress throws IllegalArgumentException on a erroring-out session in 5.3.x versions #33619

Closed
Spikhalskiy opened this issue Sep 30, 2024 · 1 comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply

Comments

@Spikhalskiy
Copy link

Spikhalskiy commented Sep 30, 2024

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+.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 30, 2024
@Spikhalskiy Spikhalskiy changed the title JettyWebSocketSession.getRemoteAddress throws IllegalArgumentExceptionon a closing session JettyWebSocketSession.getRemoteAddress throws IllegalArgumentExceptionon a closing session in 5.3.x versions Oct 1, 2024
@Spikhalskiy Spikhalskiy changed the title JettyWebSocketSession.getRemoteAddress throws IllegalArgumentExceptionon a closing session in 5.3.x versions JettyWebSocketSession.getRemoteAddress throws IllegalArgumentException on a erroring-out session in 5.3.x versions Oct 1, 2024
@bclozel
Copy link
Member

bclozel commented Oct 1, 2024

Spring Framework 5.3.x is out of open source support so we won't be releasing new versions for this generation on Maven Central.

See https://spring.io/projects/spring-framework#support

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Oct 1, 2024
@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

3 participants