Add more @Nullable parameters based on null usage
Issue: SPR-15540
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
@@ -217,7 +218,7 @@ public class WebSocketHttpHeaders extends HttpHeaders {
|
||||
* @see #set(String, String)
|
||||
*/
|
||||
@Override
|
||||
public void add(String headerName, String headerValue) {
|
||||
public void add(String headerName, @Nullable String headerValue) {
|
||||
this.headers.add(headerName, headerValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.web.socket.WebSocketExtension;
|
||||
@@ -72,7 +73,7 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
|
||||
|
||||
@Override
|
||||
public final ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
|
||||
WebSocketHttpHeaders headers, URI uri) {
|
||||
@Nullable WebSocketHttpHeaders headers, URI uri) {
|
||||
|
||||
Assert.notNull(webSocketHandler, "WebSocketHandler must not be null");
|
||||
assertUri(uri);
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.web.socket.client;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
import org.springframework.web.socket.WebSocketHttpHeaders;
|
||||
@@ -38,6 +39,6 @@ public interface WebSocketClient {
|
||||
String uriTemplate, Object... uriVariables);
|
||||
|
||||
ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
|
||||
WebSocketHttpHeaders headers, URI uri);
|
||||
@Nullable WebSocketHttpHeaders headers, URI uri);
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.simp.stomp.BufferingStompDecoder;
|
||||
import org.springframework.messaging.simp.stomp.ConnectionHandlingStompSession;
|
||||
@@ -229,7 +230,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
|
||||
* @param uriVariables URI variables to expand into the URL
|
||||
* @return ListenableFuture for access to the session when ready for use
|
||||
*/
|
||||
public ListenableFuture<StompSession> connect(String url, WebSocketHttpHeaders handshakeHeaders,
|
||||
public ListenableFuture<StompSession> connect(String url, @Nullable WebSocketHttpHeaders handshakeHeaders,
|
||||
StompSessionHandler handler, Object... uriVariables) {
|
||||
|
||||
return connect(url, handshakeHeaders, null, handler, uriVariables);
|
||||
@@ -248,7 +249,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
|
||||
* @return ListenableFuture for access to the session when ready for use
|
||||
*/
|
||||
public ListenableFuture<StompSession> connect(String url, WebSocketHttpHeaders handshakeHeaders,
|
||||
StompHeaders connectHeaders, StompSessionHandler handler, Object... uriVariables) {
|
||||
@Nullable StompHeaders connectHeaders, StompSessionHandler handler, Object... uriVariables) {
|
||||
|
||||
Assert.notNull(url, "'url' must not be null");
|
||||
URI uri = UriComponentsBuilder.fromUriString(url).buildAndExpand(uriVariables).encode().toUri();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.web.socket.sockjs;
|
||||
|
||||
import org.springframework.core.NestedRuntimeException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Base class for exceptions raised while processing SockJS HTTP requests.
|
||||
@@ -45,7 +46,7 @@ public class SockJsException extends NestedRuntimeException {
|
||||
* @param sessionId the SockJS session id
|
||||
* @param cause the root cause
|
||||
*/
|
||||
public SockJsException(String message, String sessionId, Throwable cause) {
|
||||
public SockJsException(String message, @Nullable String sessionId, @Nullable Throwable cause) {
|
||||
super(message, cause);
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.concurrent.SettableListenableFuture;
|
||||
import org.springframework.web.socket.CloseStatus;
|
||||
@@ -308,7 +309,7 @@ public abstract class AbstractClientSockJsSession implements WebSocketSession {
|
||||
}
|
||||
}
|
||||
|
||||
public void afterTransportClosed(CloseStatus closeStatus) {
|
||||
public void afterTransportClosed(@Nullable CloseStatus closeStatus) {
|
||||
this.closeStatus = (this.closeStatus != null ? this.closeStatus : closeStatus);
|
||||
Assert.state(this.closeStatus != null, "CloseStatus not available");
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.concurrent.ListenableFutureCallback;
|
||||
@@ -209,7 +210,7 @@ class DefaultTransportRequest implements TransportRequest {
|
||||
handleFailure(null, true);
|
||||
}
|
||||
|
||||
private void handleFailure(Throwable ex, boolean isTimeoutFailure) {
|
||||
private void handleFailure(@Nullable Throwable ex, boolean isTimeoutFailure) {
|
||||
if (this.handled.compareAndSet(false, true)) {
|
||||
if (isTimeoutFailure) {
|
||||
String message = "Connect timed out for " + DefaultTransportRequest.this;
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.context.Lifecycle;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.concurrent.SettableListenableFuture;
|
||||
import org.springframework.web.client.HttpServerErrorException;
|
||||
@@ -134,7 +135,7 @@ public class JettyXhrTransport extends AbstractXhrTransport implements Lifecycle
|
||||
return executeRequest(url, HttpMethod.POST, headers, message.getPayload());
|
||||
}
|
||||
|
||||
protected ResponseEntity<String> executeRequest(URI url, HttpMethod method, HttpHeaders headers, String body) {
|
||||
protected ResponseEntity<String> executeRequest(URI url, HttpMethod method, HttpHeaders headers, @Nullable String body) {
|
||||
Request httpRequest = this.httpClient.newRequest(url).method(method);
|
||||
addHttpHeaders(httpRequest, headers);
|
||||
if (body != null) {
|
||||
|
||||
@@ -239,7 +239,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle {
|
||||
|
||||
@Override
|
||||
public final ListenableFuture<WebSocketSession> doHandshake(
|
||||
WebSocketHandler handler, WebSocketHttpHeaders headers, URI url) {
|
||||
WebSocketHandler handler, @Nullable WebSocketHttpHeaders headers, URI url) {
|
||||
|
||||
Assert.notNull(handler, "WebSocketHandler is required");
|
||||
Assert.notNull(url, "URL is required");
|
||||
|
||||
@@ -26,6 +26,7 @@ import javax.servlet.ServletContext;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.web.context.ServletContextAware;
|
||||
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;
|
||||
@@ -78,7 +79,7 @@ public class DefaultSockJsService extends TransportHandlingSockJsService impleme
|
||||
}
|
||||
|
||||
|
||||
private static Set<TransportHandler> getDefaultTransportHandlers(Collection<TransportHandler> overrides) {
|
||||
private static Set<TransportHandler> getDefaultTransportHandlers(@Nullable Collection<TransportHandler> overrides) {
|
||||
Set<TransportHandler> result = new LinkedHashSet<>(8);
|
||||
result.add(new XhrPollingTransportHandler());
|
||||
result.add(new XhrReceivingTransportHandler());
|
||||
|
||||
Reference in New Issue
Block a user