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

WebSocketTransportHandler passes Collections.<String, Object>emptyMap() to HandshakeHandler [SPR-12716] #17313

Closed
spring-issuemaster opened this issue Feb 14, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Feb 14, 2015

Rob Winch opened SPR-12716 and commented

WebSocketTransportHandler passes in an empty Map into the delegate HandshakeHandler. This causes two problems:

  • The first is that no attributes that are were copied from any HandshakeInterceptor instances are available. For example, TransportHandlingSockJsService will invoke the HandshakeInterceptor and then delegate to a WebSocketTransportHandler. Since the attributes provided by the HandshakeInterceptor are not passed into the delegate HandshakeHandler
  • The second is that the delegate HandshakeHandler cannot populate any attributes to be provided in the WebSocket Session. For one Collections.<String, Object>emptyMap() is immutable. For two, the values are never copied to the WebSocket Session.

Affects: 4.1.4

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 16, 2015

Rossen Stoyanchev commented

With SockJS the actual "session" is of type SockJsSession and for the websocket transport that's WebSocketServerSockJsSession which wraps the underlying WebSocketSession instance.

The attributes map that is populated by HandshakeInterceptors is correctly passed to the SockJsSession (TransportHandlingSockJsService line 238) and that's all that should matter for the most part since no one should ever see the wrapped WebSocketSession. This is why we pass an empty map in WebSocketTransportHandler.

That said it is true that the delegate HandshakeHandler won't be able to add any attributes. Is that the actual issue you're running into? Now that I look at this again we might as well pass the attributes from the SockJsSession into the handshakeHandler, i.e. change from Collections.emptyMap to WebSocket wsSession.getAttributes.

Does that make sense?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 16, 2015

Rob Winch commented

Thanks for the response.

My actual issue is actually a bit incidental actually. I was using a TestHandshakeHandler to verify that a custom HandshakeInterceptor was properly integrated with the configuration. I felt that this is an actual issue.

I think that changing from Collections.emptyMap to wsSession.getAttributes would fix both issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.