WebSocketSession.getUri() may return null
Issue: SPR-15721
This commit is contained in:
parent
930f0f1760
commit
9afce23845
|
@ -43,7 +43,9 @@ public interface WebSocketSession extends Closeable {
|
|||
|
||||
/**
|
||||
* Return the URI used to open the WebSocket connection.
|
||||
* ({@code null} on the client side).
|
||||
*/
|
||||
@Nullable
|
||||
URI getUri();
|
||||
|
||||
/**
|
||||
|
|
|
@ -103,7 +103,7 @@ public class JettyWebSocketSession extends AbstractWebSocketSession<Session> {
|
|||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
Assert.state(this.uri != null, "WebSocket session is not yet initialized");
|
||||
checkNativeSessionInitialized();
|
||||
return this.uri;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public class StandardWebSocketSession extends AbstractWebSocketSession<Session>
|
|||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
Assert.state(this.uri != null, "WebSocket session is not yet initialized");
|
||||
checkNativeSessionInitialized();
|
||||
return this.uri;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,8 @@ public class XhrClientSockJsSession extends AbstractClientSockJsSession {
|
|||
|
||||
@Override
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
return new InetSocketAddress(getUri().getHost(), getUri().getPort());
|
||||
URI uri = getUri();
|
||||
return (uri != null ? new InetSocketAddress(uri.getHost(), uri.getPort()) : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -127,8 +127,8 @@ public abstract class AbstractSockJsSession implements SockJsSession {
|
|||
public AbstractSockJsSession(String id, SockJsServiceConfig config, WebSocketHandler handler,
|
||||
@Nullable Map<String, Object> attributes) {
|
||||
|
||||
Assert.notNull(id, "SessionId must not be null");
|
||||
Assert.notNull(config, "SockJsConfig must not be null");
|
||||
Assert.notNull(id, "Session id must not be null");
|
||||
Assert.notNull(config, "SockJsServiceConfig must not be null");
|
||||
Assert.notNull(handler, "WebSocketHandler must not be null");
|
||||
|
||||
this.id = id;
|
||||
|
|
Loading…
Reference in New Issue