Nullability fine-tuning around declaration inconsistencies
Issue: SPR-15720 Issue: SPR-15792
This commit is contained in:
@@ -144,11 +144,13 @@ public class StandardWebSocketSession extends AbstractWebSocketSession<Session>
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
return this.localAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
return this.remoteAddress;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -13,8 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.web.socket.config.annotation;
|
||||
|
||||
package org.springframework.web.socket.config.annotation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -31,10 +31,13 @@ import org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory;
|
||||
*/
|
||||
public class WebSocketTransportRegistration {
|
||||
|
||||
@Nullable
|
||||
private Integer messageSizeLimit;
|
||||
|
||||
@Nullable
|
||||
private Integer sendTimeLimit;
|
||||
|
||||
@Nullable
|
||||
private Integer sendBufferSizeLimit;
|
||||
|
||||
private final List<WebSocketHandlerDecoratorFactory> decoratorFactories = new ArrayList<>(2);
|
||||
|
||||
@@ -218,17 +218,17 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return (this == other ||
|
||||
(other instanceof SimpUser && this.name.equals(((SimpUser) other).getName())));
|
||||
(other instanceof SimpUser && getName().equals(((SimpUser) other).getName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode();
|
||||
return getName().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "name=" + this.name + ", sessions=" + this.userSessions;
|
||||
return "name=" + getName() + ", sessions=" + this.userSessions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,17 +274,17 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return (this == other ||
|
||||
(other instanceof SimpSubscription && this.id.equals(((SimpSubscription) other).getId())));
|
||||
(other instanceof SimpSubscription && getId().equals(((SimpSubscription) other).getId())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.id.hashCode();
|
||||
return getId().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "id=" + this.id + ", subscriptions=" + this.subscriptions;
|
||||
return "id=" + getId() + ", subscriptions=" + this.subscriptions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,13 +330,13 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
|
||||
return false;
|
||||
}
|
||||
SimpSubscription otherSubscription = (SimpSubscription) other;
|
||||
return (this.id.equals(otherSubscription.getId()) &&
|
||||
return (getId().equals(otherSubscription.getId()) &&
|
||||
getSession().getId().equals(otherSubscription.getSession().getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.id.hashCode() * 31 + getSession().getId().hashCode();
|
||||
return getId().hashCode() * 31 + getSession().getId().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -111,7 +111,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
|
||||
* property to "10000,10000" if it is currently set to "0,0".
|
||||
*/
|
||||
@Override
|
||||
public void setTaskScheduler(TaskScheduler taskScheduler) {
|
||||
public void setTaskScheduler(@Nullable TaskScheduler taskScheduler) {
|
||||
if (!isDefaultHeartbeatEnabled()) {
|
||||
setDefaultHeartbeat(new long[] {10000, 10000});
|
||||
}
|
||||
@@ -296,6 +296,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
|
||||
|
||||
private final StompWebSocketMessageCodec codec = new StompWebSocketMessageCodec(getInboundMessageSizeLimit());
|
||||
|
||||
@Nullable
|
||||
private volatile WebSocketSession session;
|
||||
|
||||
private volatile long lastReadTime = -1;
|
||||
@@ -312,7 +313,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
|
||||
// ListenableFutureCallback implementation: handshake outcome
|
||||
|
||||
@Override
|
||||
public void onSuccess(WebSocketSession webSocketSession) {
|
||||
public void onSuccess(@Nullable WebSocketSession webSocketSession) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -381,7 +382,9 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
|
||||
updateLastWriteTime();
|
||||
SettableListenableFuture<Void> future = new SettableListenableFuture<>();
|
||||
try {
|
||||
this.session.sendMessage(this.codec.encode(message, this.session.getClass()));
|
||||
WebSocketSession session = this.session;
|
||||
Assert.state(session != null, "No WebSocketSession available");
|
||||
session.sendMessage(this.codec.encode(message, session.getClass()));
|
||||
future.set(null);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
@@ -438,12 +441,15 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
try {
|
||||
this.session.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to close session: " + this.session.getId(), ex);
|
||||
WebSocketSession session = this.session;
|
||||
if (session != null) {
|
||||
try {
|
||||
session.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to close session: " + session.getId(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -172,7 +172,7 @@ public class HttpSessionHandshakeInterceptor implements HandshakeInterceptor {
|
||||
|
||||
@Override
|
||||
public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response,
|
||||
WebSocketHandler wsHandler, Exception ex) {
|
||||
WebSocketHandler wsHandler, @Nullable Exception ex) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
import org.springframework.web.socket.server.HandshakeInterceptor;
|
||||
@@ -103,7 +104,7 @@ public class OriginHandshakeInterceptor implements HandshakeInterceptor {
|
||||
|
||||
@Override
|
||||
public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response,
|
||||
WebSocketHandler wsHandler, Exception exception) {
|
||||
WebSocketHandler wsHandler, @Nullable Exception exception) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ class DefaultTransportRequest implements TransportRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Principal getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.util.concurrent.ListenableFutureCallback;
|
||||
@@ -87,7 +88,7 @@ public class WebSocketTransport implements Transport, Lifecycle {
|
||||
this.webSocketClient.doHandshake(handler, headers, url).addCallback(
|
||||
new ListenableFutureCallback<WebSocketSession>() {
|
||||
@Override
|
||||
public void onSuccess(WebSocketSession webSocketSession) {
|
||||
public void onSuccess(@Nullable WebSocketSession webSocketSession) {
|
||||
// WebSocket session ready, SockJS Session not yet
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -19,6 +19,8 @@ package org.springframework.web.socket.sockjs.transport.handler;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.socket.sockjs.transport.SockJsServiceConfig;
|
||||
import org.springframework.web.socket.sockjs.transport.TransportHandler;
|
||||
|
||||
@@ -32,6 +34,7 @@ public abstract class AbstractTransportHandler implements TransportHandler {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Nullable
|
||||
private SockJsServiceConfig serviceConfig;
|
||||
|
||||
|
||||
@@ -41,6 +44,7 @@ public abstract class AbstractTransportHandler implements TransportHandler {
|
||||
}
|
||||
|
||||
public SockJsServiceConfig getServiceConfig() {
|
||||
Assert.state(this.serviceConfig != null, "No SockJsServiceConfig available");
|
||||
return this.serviceConfig;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,16 +107,19 @@ public abstract class AbstractHttpSockJsSession extends AbstractSockJsSession {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Principal getPrincipal() {
|
||||
return this.principal;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
return this.localAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
return this.remoteAddress;
|
||||
}
|
||||
@@ -127,13 +130,14 @@ public abstract class AbstractHttpSockJsSession extends AbstractSockJsSession {
|
||||
* the selected protocol set through this setter.
|
||||
* @param protocol the sub-protocol to set
|
||||
*/
|
||||
public void setAcceptedProtocol(String protocol) {
|
||||
public void setAcceptedProtocol(@Nullable String protocol) {
|
||||
this.acceptedProtocol = protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the selected sub-protocol to use.
|
||||
*/
|
||||
@Nullable
|
||||
public String getAcceptedProtocol() {
|
||||
return this.acceptedProtocol;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user