diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketSession.java index 56038e240c..f21edfa013 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,10 +52,12 @@ public interface WebSocketSession extends Closeable { /** * Return the map with attributes associated with the WebSocket session. - *

When the WebSocketSession is created, on the server side, the map can be - * through a {@link org.springframework.web.socket.server.HandshakeInterceptor}. - * On the client side, the map can be populated by passing attributes to the - * {@link org.springframework.web.socket.client.WebSocketClient} handshake methods. + *

On the server side the map can be populated initially through a + * {@link org.springframework.web.socket.server.HandshakeInterceptor + * HandshakeInterceptor}. On the client side the map can be populated via + * {@link org.springframework.web.socket.client.WebSocketClient + * WebSocketClient} handshake methods. + * @return a Map with the session attributes, never {@code null}. */ Map getAttributes(); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java index df1c81617f..5a64cb0c48 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.springframework.web.socket.sockjs.transport.handler; -import java.util.Collections; import java.util.Map; import org.springframework.http.server.ServerHttpRequest; @@ -67,10 +66,8 @@ public class WebSocketTransportHandler extends AbstractTransportHandler } @Override - public AbstractSockJsSession createSession( - String sessionId, WebSocketHandler handler, Map attributes) { - - return new WebSocketServerSockJsSession(sessionId, getServiceConfig(), handler, attributes); + public AbstractSockJsSession createSession(String id, WebSocketHandler handler, Map attrs) { + return new WebSocketServerSockJsSession(id, getServiceConfig(), handler, attrs); } @Override @@ -80,7 +77,7 @@ public class WebSocketTransportHandler extends AbstractTransportHandler WebSocketServerSockJsSession sockJsSession = (WebSocketServerSockJsSession) wsSession; try { wsHandler = new SockJsWebSocketHandler(getServiceConfig(), wsHandler, sockJsSession); - this.handshakeHandler.doHandshake(request, response, wsHandler, Collections.emptyMap()); + this.handshakeHandler.doHandshake(request, response, wsHandler, sockJsSession.getAttributes()); } catch (Throwable ex) { sockJsSession.tryCloseWithSockJsTransportError(ex, CloseStatus.SERVER_ERROR);