Switch to JSpecify annotations

This commit updates the whole Spring Framework codebase to use JSpecify
annotations instead of Spring null-safety annotations with JSR 305
semantics.

JSpecify provides signficant enhancements such as properly defined
specifications, a canonical dependency with no split-package issue,
better tooling, better Kotlin integration and the capability to specify
generic type, array and varargs element null-safety. Generic type
null-safety is not defined by this commit yet and will be specified
later.

A key difference is that Spring null-safety annotations, following
JSR 305 semantics, apply to fields, parameters and return values,
while JSpecify annotations apply to type usages. That's why this
commit moves nullability annotations closer to the type for fields
and return values.

See gh-28797
This commit is contained in:
Sébastien Deleuze
2024-12-03 15:22:37 +01:00
parent fcb8aed03f
commit bc5d771a06
3459 changed files with 14118 additions and 22059 deletions

View File

@@ -16,7 +16,8 @@
package org.springframework.web.socket;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;

View File

@@ -19,7 +19,8 @@ package org.springframework.web.socket;
import java.io.Serializable;
import java.util.Objects;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -152,8 +153,7 @@ public final class CloseStatus implements Serializable {
private final int code;
@Nullable
private final String reason;
private final @Nullable String reason;
/**
@@ -186,8 +186,7 @@ public final class CloseStatus implements Serializable {
/**
* Return the reason, or {@code null} if none.
*/
@Nullable
public String getReason() {
public @Nullable String getReason() {
return this.reason;
}

View File

@@ -18,7 +18,7 @@ package org.springframework.web.socket;
import java.nio.charset.StandardCharsets;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* A text WebSocket message.
@@ -28,8 +28,7 @@ import org.springframework.lang.Nullable;
*/
public final class TextMessage extends AbstractWebSocketMessage<String> {
@Nullable
private final byte[] bytes;
private final byte @Nullable [] bytes;
/**

View File

@@ -22,7 +22,8 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedCaseInsensitiveMap;

View File

@@ -24,8 +24,9 @@ import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
/**
@@ -82,8 +83,7 @@ public class WebSocketHttpHeaders extends HttpHeaders {
* Returns the value of the {@code Sec-WebSocket-Accept} header.
* @return the value of the header
*/
@Nullable
public String getSecWebSocketAccept() {
public @Nullable String getSecWebSocketAccept() {
return getFirst(SEC_WEBSOCKET_ACCEPT);
}
@@ -129,8 +129,7 @@ public class WebSocketHttpHeaders extends HttpHeaders {
* Returns the value of the {@code Sec-WebSocket-Key} header.
* @return the value of the header
*/
@Nullable
public String getSecWebSocketKey() {
public @Nullable String getSecWebSocketKey() {
return getFirst(SEC_WEBSOCKET_KEY);
}
@@ -179,8 +178,7 @@ public class WebSocketHttpHeaders extends HttpHeaders {
* Returns the value of the {@code Sec-WebSocket-Version} header.
* @return the value of the header
*/
@Nullable
public String getSecWebSocketVersion() {
public @Nullable String getSecWebSocketVersion() {
return getFirst(SEC_WEBSOCKET_VERSION);
}
@@ -193,8 +191,7 @@ public class WebSocketHttpHeaders extends HttpHeaders {
* @return the first header value; or {@code null}
*/
@Override
@Nullable
public String getFirst(String headerName) {
public @Nullable String getFirst(String headerName) {
return this.headers.getFirst(headerName);
}
@@ -257,8 +254,7 @@ public class WebSocketHttpHeaders extends HttpHeaders {
}
@Override
@Nullable
public List<String> get(Object key) {
public @Nullable List<String> get(Object key) {
return this.headers.get(key);
}

View File

@@ -24,8 +24,9 @@ import java.security.Principal;
import java.util.List;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
/**
* A WebSocket session abstraction. Allows sending messages over a WebSocket
@@ -44,8 +45,7 @@ public interface WebSocketSession extends Closeable {
/**
* Return the URI used to open the WebSocket connection.
*/
@Nullable
URI getUri();
@Nullable URI getUri();
/**
* Return the headers used in the handshake request (never {@code null}).
@@ -68,28 +68,24 @@ public interface WebSocketSession extends Closeable {
* of the authenticated user.
* <p>If the user has not been authenticated, the method returns <code>null</code>.
*/
@Nullable
Principal getPrincipal();
@Nullable Principal getPrincipal();
/**
* Return the address on which the request was received.
*/
@Nullable
InetSocketAddress getLocalAddress();
@Nullable InetSocketAddress getLocalAddress();
/**
* Return the address of the remote client.
*/
@Nullable
InetSocketAddress getRemoteAddress();
@Nullable InetSocketAddress getRemoteAddress();
/**
* Return the negotiated sub-protocol.
* @return the protocol identifier, or {@code null} if no protocol
* was specified or negotiated successfully
*/
@Nullable
String getAcceptedProtocol();
@Nullable String getAcceptedProtocol();
/**
* Configure the maximum size for an incoming text message.

View File

@@ -22,8 +22,8 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.util.AlternativeJdkIdGenerator;
import org.springframework.util.Assert;
import org.springframework.util.IdGenerator;
@@ -51,8 +51,7 @@ public abstract class AbstractWebSocketSession<T> implements NativeWebSocketSess
private final Map<String, Object> attributes = new ConcurrentHashMap<>();
@Nullable
private T nativeSession;
private @Nullable T nativeSession;
/**
@@ -82,8 +81,7 @@ public abstract class AbstractWebSocketSession<T> implements NativeWebSocketSess
@SuppressWarnings("unchecked")
@Override
@Nullable
public <R> R getNativeSession(@Nullable Class<R> requiredType) {
public <R> @Nullable R getNativeSession(@Nullable Class<R> requiredType) {
return (requiredType == null || requiredType.isInstance(this.nativeSession) ? (R) this.nativeSession : null);
}

View File

@@ -16,7 +16,8 @@
package org.springframework.web.socket.adapter;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.web.socket.WebSocketSession;
/**
@@ -39,7 +40,6 @@ public interface NativeWebSocketSession extends WebSocketSession {
* @return the native session of the required type,
* or {@code null} if not available
*/
@Nullable
<T> T getNativeSession(@Nullable Class<T> requiredType);
<T> @Nullable T getNativeSession(@Nullable Class<T> requiredType);
}

View File

@@ -23,8 +23,8 @@ import org.apache.commons.logging.LogFactory;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.Callback;
import org.eclipse.jetty.websocket.api.Session;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.socket.BinaryMessage;
import org.springframework.web.socket.CloseStatus;
@@ -47,8 +47,7 @@ public class JettyWebSocketHandlerAdapter implements Session.Listener {
private final JettyWebSocketSession wsSession;
@Nullable
private Session nativeSession;
private @Nullable Session nativeSession;
public JettyWebSocketHandlerAdapter(WebSocketHandler webSocketHandler, JettyWebSocketSession wsSession) {

View File

@@ -30,9 +30,9 @@ import java.util.concurrent.ExecutionException;
import org.eclipse.jetty.websocket.api.Callback;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.api.Session;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.web.socket.BinaryMessage;
@@ -57,20 +57,15 @@ public class JettyWebSocketSession extends AbstractWebSocketSession<Session> {
private final String id;
@Nullable
private URI uri;
private @Nullable URI uri;
@Nullable
private HttpHeaders headers;
private @Nullable HttpHeaders headers;
@Nullable
private String acceptedProtocol;
private @Nullable String acceptedProtocol;
@Nullable
private List<WebSocketExtension> extensions;
private @Nullable List<WebSocketExtension> extensions;
@Nullable
private Principal user;
private @Nullable Principal user;
/**
@@ -101,8 +96,7 @@ public class JettyWebSocketSession extends AbstractWebSocketSession<Session> {
}
@Override
@Nullable
public URI getUri() {
public @Nullable URI getUri() {
checkNativeSessionInitialized();
return this.uri;
}
@@ -114,8 +108,7 @@ public class JettyWebSocketSession extends AbstractWebSocketSession<Session> {
}
@Override
@Nullable
public String getAcceptedProtocol() {
public @Nullable String getAcceptedProtocol() {
checkNativeSessionInitialized();
return this.acceptedProtocol;
}
@@ -127,8 +120,7 @@ public class JettyWebSocketSession extends AbstractWebSocketSession<Session> {
}
@Override
@Nullable
public Principal getPrincipal() {
public @Nullable Principal getPrincipal() {
return this.user;
}

View File

@@ -1,9 +1,7 @@
/**
* Adapter classes for the Jetty WebSocket API.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.adapter.jetty;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -1,9 +1,7 @@
/**
* Classes adapting Spring's WebSocket API to and from WebSocket providers.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.adapter;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -23,6 +23,7 @@ import jakarta.websocket.Decoder;
import jakarta.websocket.EncodeException;
import jakarta.websocket.Encoder;
import jakarta.websocket.EndpointConfig;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -33,7 +34,6 @@ import org.springframework.core.GenericTypeResolver;
import org.springframework.core.convert.ConversionException;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.context.ContextLoader;
@@ -124,8 +124,7 @@ public abstract class ConvertingEncoderDecoderSupport<T, M> {
* not using {@link ContextLoader}, this method should be overridden.
* @return the {@link ApplicationContext} or {@code null}
*/
@Nullable
protected ApplicationContext getApplicationContext() {
protected @Nullable ApplicationContext getApplicationContext() {
return ContextLoader.getCurrentWebApplicationContext();
}
@@ -160,8 +159,7 @@ public abstract class ConvertingEncoderDecoderSupport<T, M> {
* @see jakarta.websocket.Encoder.Binary#encode(Object)
*/
@SuppressWarnings("unchecked")
@Nullable
public M encode(T object) throws EncodeException {
public @Nullable M encode(T object) throws EncodeException {
try {
return (M) getConversionService().convert(object, getType(), getMessageType());
}
@@ -186,8 +184,7 @@ public abstract class ConvertingEncoderDecoderSupport<T, M> {
* @see jakarta.websocket.Decoder.Binary#decode(ByteBuffer)
*/
@SuppressWarnings("unchecked")
@Nullable
public T decode(M message) throws DecodeException {
public @Nullable T decode(M message) throws DecodeException {
try {
return (T) getConversionService().convert(message, getMessageType(), getType());
}

View File

@@ -29,9 +29,9 @@ import jakarta.websocket.CloseReason;
import jakarta.websocket.CloseReason.CloseCodes;
import jakarta.websocket.Extension;
import jakarta.websocket.Session;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.web.socket.BinaryMessage;
@@ -53,25 +53,19 @@ public class StandardWebSocketSession extends AbstractWebSocketSession<Session>
private final String id;
@Nullable
private URI uri;
private @Nullable URI uri;
private final HttpHeaders handshakeHeaders;
@Nullable
private String acceptedProtocol;
private @Nullable String acceptedProtocol;
@Nullable
private List<WebSocketExtension> extensions;
private @Nullable List<WebSocketExtension> extensions;
@Nullable
private Principal user;
private @Nullable Principal user;
@Nullable
private final InetSocketAddress localAddress;
private final @Nullable InetSocketAddress localAddress;
@Nullable
private final InetSocketAddress remoteAddress;
private final @Nullable InetSocketAddress remoteAddress;
/**
@@ -117,8 +111,7 @@ public class StandardWebSocketSession extends AbstractWebSocketSession<Session>
}
@Override
@Nullable
public URI getUri() {
public @Nullable URI getUri() {
checkNativeSessionInitialized();
return this.uri;
}
@@ -129,8 +122,7 @@ public class StandardWebSocketSession extends AbstractWebSocketSession<Session>
}
@Override
@Nullable
public String getAcceptedProtocol() {
public @Nullable String getAcceptedProtocol() {
checkNativeSessionInitialized();
return this.acceptedProtocol;
}
@@ -142,20 +134,17 @@ public class StandardWebSocketSession extends AbstractWebSocketSession<Session>
}
@Override
@Nullable
public Principal getPrincipal() {
public @Nullable Principal getPrincipal() {
return this.user;
}
@Override
@Nullable
public InetSocketAddress getLocalAddress() {
public @Nullable InetSocketAddress getLocalAddress() {
return this.localAddress;
}
@Override
@Nullable
public InetSocketAddress getRemoteAddress() {
public @Nullable InetSocketAddress getRemoteAddress() {
return this.remoteAddress;
}

View File

@@ -20,8 +20,8 @@ import java.util.ArrayList;
import java.util.List;
import jakarta.websocket.Extension;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.web.socket.WebSocketExtension;
/**
@@ -47,8 +47,7 @@ public class WebSocketToStandardExtensionAdapter implements Extension {
return paramName;
}
@Override
@Nullable
public String getValue() {
public @Nullable String getValue() {
return extension.getParameters().get(paramName);
}
});

View File

@@ -1,9 +1,7 @@
/**
* Adapter classes for the standard Jakarta WebSocket API.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.adapter.standard;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -26,9 +26,9 @@ import java.util.concurrent.CompletableFuture;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.socket.WebSocketExtension;
import org.springframework.web.socket.WebSocketHandler;

View File

@@ -19,7 +19,8 @@ package org.springframework.web.socket.client;
import java.net.URI;
import java.util.concurrent.CompletableFuture;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.WebSocketHttpHeaders;
import org.springframework.web.socket.WebSocketSession;

View File

@@ -20,9 +20,10 @@ import java.net.URI;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.jspecify.annotations.Nullable;
import org.springframework.context.Lifecycle;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.WebSocketHttpHeaders;
import org.springframework.web.socket.WebSocketSession;
@@ -43,8 +44,7 @@ public class WebSocketConnectionManager extends ConnectionManagerSupport {
private final WebSocketHandler webSocketHandler;
@Nullable
private WebSocketSession webSocketSession;
private @Nullable WebSocketSession webSocketSession;
private final WebSocketHttpHeaders headers = new WebSocketHttpHeaders();
@@ -99,8 +99,7 @@ public class WebSocketConnectionManager extends ConnectionManagerSupport {
/**
* Return the configured origin.
*/
@Nullable
public String getOrigin() {
public @Nullable String getOrigin() {
return this.headers.getOrigin();
}

View File

@@ -1,9 +1,7 @@
/**
* Client-side abstractions for WebSocket applications.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.client;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -19,13 +19,13 @@ package org.springframework.web.socket.client.standard;
import jakarta.websocket.ContainerProvider;
import jakarta.websocket.Session;
import jakarta.websocket.WebSocketContainer;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.socket.client.ConnectionManagerSupport;
import org.springframework.web.socket.handler.BeanCreatingHandlerProvider;
@@ -40,18 +40,15 @@ import org.springframework.web.socket.handler.BeanCreatingHandlerProvider;
*/
public class AnnotatedEndpointConnectionManager extends ConnectionManagerSupport implements BeanFactoryAware {
@Nullable
private final Object endpoint;
private final @Nullable Object endpoint;
@Nullable
private final BeanCreatingHandlerProvider<Object> endpointProvider;
private final @Nullable BeanCreatingHandlerProvider<Object> endpointProvider;
private WebSocketContainer webSocketContainer = ContainerProvider.getWebSocketContainer();
private TaskExecutor taskExecutor = new SimpleAsyncTaskExecutor("AnnotatedEndpointConnectionManager-");
@Nullable
private volatile Session session;
private volatile @Nullable Session session;
public AnnotatedEndpointConnectionManager(Object endpoint, String uriTemplate, Object... uriVariables) {

View File

@@ -28,12 +28,12 @@ import jakarta.websocket.Endpoint;
import jakarta.websocket.Extension;
import jakarta.websocket.Session;
import jakarta.websocket.WebSocketContainer;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.socket.client.ConnectionManagerSupport;
import org.springframework.web.socket.handler.BeanCreatingHandlerProvider;
@@ -49,11 +49,9 @@ import org.springframework.web.socket.handler.BeanCreatingHandlerProvider;
*/
public class EndpointConnectionManager extends ConnectionManagerSupport implements BeanFactoryAware {
@Nullable
private final Endpoint endpoint;
private final @Nullable Endpoint endpoint;
@Nullable
private final BeanCreatingHandlerProvider<Endpoint> endpointProvider;
private final @Nullable BeanCreatingHandlerProvider<Endpoint> endpointProvider;
private final ClientEndpointConfig.Builder configBuilder = ClientEndpointConfig.Builder.create();
@@ -61,8 +59,7 @@ public class EndpointConnectionManager extends ConnectionManagerSupport implemen
private TaskExecutor taskExecutor = new SimpleAsyncTaskExecutor("EndpointConnectionManager-");
@Nullable
private volatile Session session;
private volatile @Nullable Session session;
public EndpointConnectionManager(Endpoint endpoint, String uriTemplate, Object... uriVariables) {

View File

@@ -37,11 +37,11 @@ import jakarta.websocket.Endpoint;
import jakarta.websocket.Extension;
import jakarta.websocket.HandshakeResponse;
import jakarta.websocket.WebSocketContainer;
import org.jspecify.annotations.Nullable;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.concurrent.FutureUtils;
import org.springframework.web.socket.WebSocketExtension;
@@ -65,11 +65,9 @@ public class StandardWebSocketClient extends AbstractWebSocketClient {
private final Map<String,Object> userProperties = new HashMap<>();
@Nullable
private SSLContext sslContext;
private @Nullable SSLContext sslContext;
@Nullable
private AsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
private @Nullable AsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
/**
@@ -124,8 +122,7 @@ public class StandardWebSocketClient extends AbstractWebSocketClient {
* Return the {@link SSLContext} to use.
* @since 6.1.3
*/
@Nullable
public SSLContext getSslContext() {
public @Nullable SSLContext getSslContext() {
return this.sslContext;
}
@@ -142,8 +139,7 @@ public class StandardWebSocketClient extends AbstractWebSocketClient {
/**
* Return the configured {@link AsyncTaskExecutor}.
*/
@Nullable
public AsyncTaskExecutor getTaskExecutor() {
public @Nullable AsyncTaskExecutor getTaskExecutor() {
return this.taskExecutor;
}

View File

@@ -1,9 +1,7 @@
/**
* Client-side classes for use with standard Jakarta WebSocket endpoints.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.client.standard;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -19,6 +19,7 @@ package org.springframework.web.socket.config;
import java.util.Arrays;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -31,7 +32,6 @@ import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
@@ -58,8 +58,7 @@ class HandlersBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext context) {
public @Nullable BeanDefinition parse(Element element, ParserContext context) {
Object source = context.extractSource(element);
CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
context.pushContainingComponent(compDefinition);

View File

@@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.w3c.dom.Element;
import org.springframework.beans.MutablePropertyValues;
@@ -38,7 +39,6 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean;
import org.springframework.lang.Nullable;
import org.springframework.messaging.converter.ByteArrayMessageConverter;
import org.springframework.messaging.converter.CompositeMessageConverter;
import org.springframework.messaging.converter.DefaultContentTypeResolver;
@@ -133,8 +133,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext context) {
public @Nullable BeanDefinition parse(Element element, ParserContext context) {
Object source = context.extractSource(element);
CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
context.pushContainingComponent(compDefinition);
@@ -277,8 +276,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
return new RuntimeBeanReference(name);
}
@Nullable
private RootBeanDefinition getDefaultExecutorBeanDefinition(String channelName) {
private @Nullable RootBeanDefinition getDefaultExecutorBeanDefinition(String channelName) {
if (channelName.equals("brokerChannel")) {
return null;
}
@@ -588,8 +586,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
registerBeanDef(beanDef, context, source);
}
@Nullable
private RuntimeBeanReference getValidator(
private @Nullable RuntimeBeanReference getValidator(
Element messageBrokerElement, @Nullable Object source, ParserContext context) {
if (messageBrokerElement.hasAttribute("validator")) {

View File

@@ -25,10 +25,10 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.core.task.TaskExecutor;
import org.springframework.lang.Nullable;
import org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler;
import org.springframework.scheduling.SchedulingTaskExecutor;
import org.springframework.scheduling.TaskScheduler;
@@ -61,26 +61,19 @@ public class WebSocketMessageBrokerStats implements SmartInitializingSingleton {
private static final Log logger = LogFactory.getLog(WebSocketMessageBrokerStats.class);
@Nullable
private SubProtocolWebSocketHandler webSocketHandler;
private @Nullable SubProtocolWebSocketHandler webSocketHandler;
@Nullable
private StompSubProtocolHandler stompSubProtocolHandler;
private @Nullable StompSubProtocolHandler stompSubProtocolHandler;
@Nullable
private StompBrokerRelayMessageHandler stompBrokerRelay;
private @Nullable StompBrokerRelayMessageHandler stompBrokerRelay;
@Nullable
private TaskExecutor inboundChannelExecutor;
private @Nullable TaskExecutor inboundChannelExecutor;
@Nullable
private TaskExecutor outboundChannelExecutor;
private @Nullable TaskExecutor outboundChannelExecutor;
@Nullable
private TaskScheduler sockJsTaskScheduler;
private @Nullable TaskScheduler sockJsTaskScheduler;
@Nullable
private ScheduledFuture<?> loggingTask;
private @Nullable ScheduledFuture<?> loggingTask;
private long loggingPeriod = TimeUnit.MINUTES.toMillis(30);
@@ -132,8 +125,7 @@ public class WebSocketMessageBrokerStats implements SmartInitializingSingleton {
this.loggingTask = initLoggingTask(TimeUnit.MINUTES.toMillis(1));
}
@Nullable
private StompSubProtocolHandler initStompSubProtocolHandler() {
private @Nullable StompSubProtocolHandler initStompSubProtocolHandler() {
if (this.webSocketHandler == null) {
return null;
}
@@ -149,8 +141,7 @@ public class WebSocketMessageBrokerStats implements SmartInitializingSingleton {
return null;
}
@Nullable
private ScheduledFuture<?> initLoggingTask(long initialDelay) {
private @Nullable ScheduledFuture<?> initLoggingTask(long initialDelay) {
if (this.sockJsTaskScheduler != null && this.loggingPeriod > 0 && logger.isInfoEnabled()) {
return this.sockJsTaskScheduler.scheduleWithFixedDelay(
() -> logger.info(WebSocketMessageBrokerStats.this.toString()),
@@ -166,8 +157,7 @@ public class WebSocketMessageBrokerStats implements SmartInitializingSingleton {
* is configured.
* @since 6.2
*/
@Nullable
public SubProtocolWebSocketHandler.Stats getWebSocketSessionStats() {
public SubProtocolWebSocketHandler.@Nullable Stats getWebSocketSessionStats() {
return (this.webSocketHandler != null ? this.webSocketHandler.getStats() : null);
}
@@ -176,8 +166,7 @@ public class WebSocketMessageBrokerStats implements SmartInitializingSingleton {
* Can return {@code null} if no {@link SubProtocolHandler} was found.
* @since 6.2
*/
@Nullable
public StompSubProtocolHandler.Stats getStompSubProtocolStats() {
public StompSubProtocolHandler.@Nullable Stats getStompSubProtocolStats() {
return (this.stompSubProtocolHandler != null ? this.stompSubProtocolHandler.getStats() : null);
}
@@ -187,8 +176,7 @@ public class WebSocketMessageBrokerStats implements SmartInitializingSingleton {
* is configured.
* @since 6.2
*/
@Nullable
public StompBrokerRelayMessageHandler.Stats getStompBrokerRelayStats() {
public StompBrokerRelayMessageHandler.@Nullable Stats getStompBrokerRelayStats() {
return (this.stompBrokerRelay != null ? this.stompBrokerRelay.getStats() : null);
}

View File

@@ -19,6 +19,7 @@ package org.springframework.web.socket.config;
import java.util.Arrays;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -27,7 +28,6 @@ import org.springframework.beans.factory.parsing.BeanComponentDefinition;
import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.lang.Nullable;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
@@ -64,8 +64,7 @@ abstract class WebSocketNamespaceUtils {
return handlerRef;
}
@Nullable
public static RuntimeBeanReference registerSockJsService(
public static @Nullable RuntimeBeanReference registerSockJsService(
Element element, String schedulerName, ParserContext context, @Nullable Object source) {
Element sockJsElement = DomUtils.getChildElementByTagName(element, "sockjs");

View File

@@ -20,7 +20,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@@ -47,8 +48,7 @@ public abstract class AbstractWebSocketHandlerRegistration<M> implements WebSock
private final MultiValueMap<WebSocketHandler, String> handlerMap = new LinkedMultiValueMap<>();
@Nullable
private HandshakeHandler handshakeHandler;
private @Nullable HandshakeHandler handshakeHandler;
private final List<HandshakeInterceptor> interceptors = new ArrayList<>();
@@ -56,8 +56,7 @@ public abstract class AbstractWebSocketHandlerRegistration<M> implements WebSock
private final List<String> allowedOriginPatterns = new ArrayList<>();
@Nullable
private SockJsServiceRegistration sockJsServiceRegistration;
private @Nullable SockJsServiceRegistration sockJsServiceRegistration;
@Override
@@ -74,8 +73,7 @@ public abstract class AbstractWebSocketHandlerRegistration<M> implements WebSock
return this;
}
@Nullable
protected HandshakeHandler getHandshakeHandler() {
protected @Nullable HandshakeHandler getHandshakeHandler() {
return this.handshakeHandler;
}
@@ -143,8 +141,7 @@ public abstract class AbstractWebSocketHandlerRegistration<M> implements WebSock
* if the application did not provide one. This should be done prior to
* calling {@link #getMappings()}.
*/
@Nullable
protected SockJsServiceRegistration getSockJsServiceRegistration() {
protected @Nullable SockJsServiceRegistration getSockJsServiceRegistration() {
return this.sockJsServiceRegistration;
}

View File

@@ -22,7 +22,8 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.util.MultiValueMap;
import org.springframework.web.HttpRequestHandler;
@@ -45,8 +46,7 @@ public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry
private int order = 1;
@Nullable
private UrlPathHelper urlPathHelper;
private @Nullable UrlPathHelper urlPathHelper;
public ServletWebSocketHandlerRegistry() {
@@ -82,8 +82,7 @@ public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry
this.urlPathHelper = urlPathHelper;
}
@Nullable
public UrlPathHelper getUrlPathHelper() {
public @Nullable UrlPathHelper getUrlPathHelper() {
return this.urlPathHelper;
}

View File

@@ -20,7 +20,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -41,29 +42,21 @@ import org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsServ
*/
public class SockJsServiceRegistration {
@Nullable
private TaskScheduler scheduler;
private @Nullable TaskScheduler scheduler;
@Nullable
private String clientLibraryUrl;
private @Nullable String clientLibraryUrl;
@Nullable
private Integer streamBytesLimit;
private @Nullable Integer streamBytesLimit;
@Nullable
private Boolean sessionCookieNeeded;
private @Nullable Boolean sessionCookieNeeded;
@Nullable
private Long heartbeatTime;
private @Nullable Long heartbeatTime;
@Nullable
private Long disconnectDelay;
private @Nullable Long disconnectDelay;
@Nullable
private Integer httpMessageCacheSize;
private @Nullable Integer httpMessageCacheSize;
@Nullable
private Boolean webSocketEnabled;
private @Nullable Boolean webSocketEnabled;
private final List<TransportHandler> transportHandlers = new ArrayList<>();
@@ -75,11 +68,9 @@ public class SockJsServiceRegistration {
private final List<String> allowedOriginPatterns = new ArrayList<>();
@Nullable
private Boolean suppressCors;
private @Nullable Boolean suppressCors;
@Nullable
private SockJsMessageCodec messageCodec;
private @Nullable SockJsMessageCodec messageCodec;
public SockJsServiceRegistration() {
@@ -310,8 +301,7 @@ public class SockJsServiceRegistration {
/**
* Return the TaskScheduler, if configured.
*/
@Nullable
protected TaskScheduler getTaskScheduler() {
protected @Nullable TaskScheduler getTaskScheduler() {
return this.scheduler;
}

View File

@@ -21,8 +21,9 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.context.ApplicationContext;
import org.springframework.lang.Nullable;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.util.Assert;
import org.springframework.util.MultiValueMap;
@@ -52,8 +53,7 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
private int order = 1;
@Nullable
private UrlPathHelper urlPathHelper;
private @Nullable UrlPathHelper urlPathHelper;
private final SubProtocolWebSocketHandler subProtocolWebSocketHandler;
@@ -131,8 +131,7 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
this.urlPathHelper = urlPathHelper;
}
@Nullable
protected UrlPathHelper getUrlPathHelper() {
protected @Nullable UrlPathHelper getUrlPathHelper() {
return this.urlPathHelper;
}

View File

@@ -20,7 +20,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
@@ -51,8 +52,7 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE
private final TaskScheduler sockJsTaskScheduler;
@Nullable
private HandshakeHandler handshakeHandler;
private @Nullable HandshakeHandler handshakeHandler;
private final List<HandshakeInterceptor> interceptors = new ArrayList<>();
@@ -60,8 +60,7 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE
private final List<String> allowedOriginPatterns = new ArrayList<>();
@Nullable
private SockJsServiceRegistration registration;
private @Nullable SockJsServiceRegistration registration;
public WebMvcStompWebSocketEndpointRegistration(

View File

@@ -16,11 +16,12 @@
package org.springframework.web.socket.config.annotation;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.lang.Nullable;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.Assert;
@@ -35,8 +36,7 @@ import org.springframework.web.servlet.HandlerMapping;
*/
public class WebSocketConfigurationSupport {
@Nullable
private ServletWebSocketHandlerRegistry handlerRegistry;
private @Nullable ServletWebSocketHandlerRegistry handlerRegistry;
@Bean
@@ -100,15 +100,13 @@ public class WebSocketConfigurationSupport {
static class DefaultSockJsSchedulerContainer implements InitializingBean, DisposableBean {
@Nullable
private final ThreadPoolTaskScheduler scheduler;
private final @Nullable ThreadPoolTaskScheduler scheduler;
DefaultSockJsSchedulerContainer(@Nullable ThreadPoolTaskScheduler scheduler) {
this.scheduler = scheduler;
}
@Nullable
public ThreadPoolTaskScheduler getScheduler() {
public @Nullable ThreadPoolTaskScheduler getScheduler() {
return this.scheduler;
}

View File

@@ -16,13 +16,14 @@
package org.springframework.web.socket.config.annotation;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.CustomScopeConfigurer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.core.task.TaskExecutor;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.lang.Nullable;
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.messaging.simp.SimpSessionScope;
@@ -59,8 +60,7 @@ import org.springframework.web.socket.server.support.WebSocketHandlerMapping;
*/
public abstract class WebSocketMessageBrokerConfigurationSupport extends AbstractMessageBrokerConfiguration {
@Nullable
private WebSocketTransportRegistration transportRegistration;
private @Nullable WebSocketTransportRegistration transportRegistration;
@Override

View File

@@ -18,8 +18,9 @@ package org.springframework.web.socket.config.annotation;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.context.SmartLifecycle;
import org.springframework.lang.Nullable;
import org.springframework.messaging.converter.MessageConverter;
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver;
import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler;
@@ -123,8 +124,7 @@ public interface WebSocketMessageBrokerConfigurer {
* @since 6.1.4
* @see SmartLifecycle
*/
@Nullable
default Integer getPhase() {
default @Nullable Integer getPhase() {
return null;
}

View File

@@ -20,7 +20,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory;
/**
@@ -31,17 +32,13 @@ import org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory;
*/
public class WebSocketTransportRegistration {
@Nullable
private Integer messageSizeLimit;
private @Nullable Integer messageSizeLimit;
@Nullable
private Integer sendTimeLimit;
private @Nullable Integer sendTimeLimit;
@Nullable
private Integer sendBufferSizeLimit;
private @Nullable Integer sendBufferSizeLimit;
@Nullable
private Integer timeToFirstMessage;
private @Nullable Integer timeToFirstMessage;
private final List<WebSocketHandlerDecoratorFactory> decoratorFactories = new ArrayList<>(2);
@@ -62,8 +59,7 @@ public class WebSocketTransportRegistration {
/**
* Protected accessor for internal use.
*/
@Nullable
protected Integer getMessageSizeLimit() {
protected @Nullable Integer getMessageSizeLimit() {
return this.messageSizeLimit;
}
@@ -104,8 +100,7 @@ public class WebSocketTransportRegistration {
/**
* Protected accessor for internal use.
*/
@Nullable
protected Integer getSendTimeLimit() {
protected @Nullable Integer getSendTimeLimit() {
return this.sendTimeLimit;
}
@@ -141,8 +136,7 @@ public class WebSocketTransportRegistration {
/**
* Protected accessor for internal use.
*/
@Nullable
protected Integer getSendBufferSizeLimit() {
protected @Nullable Integer getSendBufferSizeLimit() {
return this.sendBufferSizeLimit;
}
@@ -165,8 +159,7 @@ public class WebSocketTransportRegistration {
/**
* Protected accessor for internal use.
*/
@Nullable
protected Integer getTimeToFirstMessage() {
protected @Nullable Integer getTimeToFirstMessage() {
return this.timeToFirstMessage;
}

View File

@@ -1,9 +1,7 @@
/**
* Support for annotation-based WebSocket setup in configuration classes.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.config.annotation;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -1,9 +1,7 @@
/**
* Configuration support for WebSocket request handling.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.config;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -16,11 +16,12 @@
package org.springframework.web.socket.handler;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -36,8 +37,7 @@ public class BeanCreatingHandlerProvider<T> implements BeanFactoryAware {
private final Class<? extends T> handlerType;
@Nullable
private AutowireCapableBeanFactory beanFactory;
private @Nullable AutowireCapableBeanFactory beanFactory;
public BeanCreatingHandlerProvider(Class<? extends T> handlerType) {

View File

@@ -26,8 +26,8 @@ import java.util.function.Consumer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.WebSocketMessage;
import org.springframework.web.socket.WebSocketSession;
@@ -56,8 +56,7 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat
private final OverflowStrategy overflowStrategy;
@Nullable
private Consumer<WebSocketMessage<?>> preSendCallback;
private @Nullable Consumer<WebSocketMessage<?>> preSendCallback;
private final Queue<WebSocketMessage<?>> buffer = new LinkedBlockingQueue<>();

View File

@@ -16,7 +16,8 @@
package org.springframework.web.socket.handler;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.web.socket.CloseStatus;
/**

View File

@@ -23,8 +23,9 @@ import java.security.Principal;
import java.util.List;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.WebSocketExtension;
@@ -80,8 +81,7 @@ public class WebSocketSessionDecorator implements WebSocketSession {
}
@Override
@Nullable
public URI getUri() {
public @Nullable URI getUri() {
return this.delegate.getUri();
}
@@ -96,26 +96,22 @@ public class WebSocketSessionDecorator implements WebSocketSession {
}
@Override
@Nullable
public Principal getPrincipal() {
public @Nullable Principal getPrincipal() {
return this.delegate.getPrincipal();
}
@Override
@Nullable
public InetSocketAddress getLocalAddress() {
public @Nullable InetSocketAddress getLocalAddress() {
return this.delegate.getLocalAddress();
}
@Override
@Nullable
public InetSocketAddress getRemoteAddress() {
public @Nullable InetSocketAddress getRemoteAddress() {
return this.delegate.getRemoteAddress();
}
@Override
@Nullable
public String getAcceptedProtocol() {
public @Nullable String getAcceptedProtocol() {
return this.delegate.getAcceptedProtocol();
}

View File

@@ -2,9 +2,7 @@
* Convenient {@link org.springframework.web.socket.WebSocketHandler}
* implementations and decorators.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.handler;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -18,8 +18,9 @@ package org.springframework.web.socket.messaging;
import java.security.Principal;
import org.jspecify.annotations.Nullable;
import org.springframework.context.ApplicationEvent;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
@@ -35,8 +36,7 @@ public abstract class AbstractSubProtocolEvent extends ApplicationEvent {
private final Message<byte[]> message;
@Nullable
private final Principal user;
private final @Nullable Principal user;
/**
@@ -79,8 +79,7 @@ public abstract class AbstractSubProtocolEvent extends ApplicationEvent {
/**
* Return the user for the session associated with the event.
*/
@Nullable
public Principal getUser() {
public @Nullable Principal getUser() {
return this.user;
}

View File

@@ -22,10 +22,11 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.jspecify.annotations.Nullable;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.SmartApplicationListener;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
@@ -152,8 +153,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
// SimpUserRegistry methods
@Override
@Nullable
public SimpUser getUser(String userName) {
public @Nullable SimpUser getUser(String userName) {
return this.users.get(userName);
}
@@ -206,9 +206,8 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
return this.name;
}
@Nullable
@Override
public Principal getPrincipal() {
public @Nullable Principal getPrincipal() {
return this.user;
}
@@ -218,8 +217,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
}
@Override
@Nullable
public SimpSession getSession(@Nullable String sessionId) {
public @Nullable SimpSession getSession(@Nullable String sessionId) {
return (sessionId != null ? this.userSessions.get(sessionId) : null);
}

View File

@@ -18,7 +18,8 @@ package org.springframework.web.socket.messaging;
import java.security.Principal;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.messaging.Message;
/**

View File

@@ -18,7 +18,8 @@ package org.springframework.web.socket.messaging;
import java.security.Principal;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.messaging.Message;
/**

View File

@@ -18,7 +18,8 @@ package org.springframework.web.socket.messaging;
import java.security.Principal;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
import org.springframework.web.socket.CloseStatus;

View File

@@ -18,7 +18,8 @@ package org.springframework.web.socket.messaging;
import java.security.Principal;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.messaging.Message;
/**

View File

@@ -18,7 +18,8 @@ package org.springframework.web.socket.messaging;
import java.security.Principal;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.messaging.Message;
/**

View File

@@ -16,7 +16,8 @@
package org.springframework.web.socket.messaging;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.simp.stomp.StompCommand;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
@@ -36,8 +37,7 @@ public class StompSubProtocolErrorHandler implements SubProtocolErrorHandler<byt
@Override
@Nullable
public Message<byte[]> handleClientMessageProcessingError(@Nullable Message<byte[]> clientMessage, Throwable ex) {
public @Nullable Message<byte[]> handleClientMessageProcessingError(@Nullable Message<byte[]> clientMessage, Throwable ex) {
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.ERROR);
accessor.setMessage(ex.getMessage());
accessor.setLeaveMutable(true);
@@ -57,8 +57,7 @@ public class StompSubProtocolErrorHandler implements SubProtocolErrorHandler<byt
}
@Override
@Nullable
public Message<byte[]> handleErrorMessageToClient(Message<byte[]> errorMessage) {
public @Nullable Message<byte[]> handleErrorMessageToClient(Message<byte[]> errorMessage) {
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(errorMessage, StompHeaderAccessor.class);
Assert.notNull(accessor, "No StompHeaderAccessor");
if (!accessor.isMutable()) {

View File

@@ -28,11 +28,11 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.simp.SimpAttributes;
@@ -94,8 +94,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
private static final byte[] EMPTY_PAYLOAD = new byte[0];
@Nullable
private StompSubProtocolErrorHandler errorHandler;
private @Nullable StompSubProtocolErrorHandler errorHandler;
private int messageSizeLimit = 64 * 1024;
@@ -105,19 +104,15 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
private final Map<String, BufferingStompDecoder> decoders = new ConcurrentHashMap<>();
@Nullable
private MessageHeaderInitializer headerInitializer;
private @Nullable MessageHeaderInitializer headerInitializer;
@Nullable
private Map<String, MessageChannel> orderedHandlingMessageChannels;
private @Nullable Map<String, MessageChannel> orderedHandlingMessageChannels;
private final Map<String, Principal> stompAuthentications = new ConcurrentHashMap<>();
@Nullable
private Boolean immutableMessageInterceptorPresent;
private @Nullable Boolean immutableMessageInterceptorPresent;
@Nullable
private ApplicationEventPublisher eventPublisher;
private @Nullable ApplicationEventPublisher eventPublisher;
private final DefaultStats stats = new DefaultStats();
@@ -136,8 +131,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
/**
* Return the configured error handler.
*/
@Nullable
public StompSubProtocolErrorHandler getErrorHandler() {
public @Nullable StompSubProtocolErrorHandler getErrorHandler() {
return this.errorHandler;
}
@@ -191,8 +185,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
/**
* Return the configured header initializer.
*/
@Nullable
public MessageHeaderInitializer getHeaderInitializer() {
public @Nullable MessageHeaderInitializer getHeaderInitializer() {
return this.headerInitializer;
}
@@ -377,8 +370,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
}
}
@Nullable
private Principal getUser(WebSocketSession session) {
private @Nullable Principal getUser(WebSocketSession session) {
Principal user = this.stompAuthentications.get(session.getId());
return (user != null ? user : session.getPrincipal());
}
@@ -619,8 +611,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
return connectedHeaders;
}
@Nullable
private String getDisconnectReceipt(SimpMessageHeaderAccessor simpHeaders) {
private @Nullable String getDisconnectReceipt(SimpMessageHeaderAccessor simpHeaders) {
String name = StompHeaderAccessor.DISCONNECT_MESSAGE_HEADER;
Message<?> message = (Message<?>) simpHeaders.getHeader(name);
if (message != null) {
@@ -657,8 +648,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
}
@Override
@Nullable
public String resolveSessionId(Message<?> message) {
public @Nullable String resolveSessionId(Message<?> message) {
return SimpMessageHeaderAccessor.getSessionId(message.getHeaders());
}

View File

@@ -16,7 +16,8 @@
package org.springframework.web.socket.messaging;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.messaging.Message;
/**
@@ -41,8 +42,7 @@ public interface SubProtocolErrorHandler<P> {
* @return the error message to send to the client, or {@code null} in which
* case no message will be sent.
*/
@Nullable
Message<P> handleClientMessageProcessingError(@Nullable Message<P> clientMessage, Throwable ex);
@Nullable Message<P> handleClientMessageProcessingError(@Nullable Message<P> clientMessage, Throwable ex);
/**
* Handle errors sent from the server side to clients, for example, errors from the
@@ -53,7 +53,6 @@ public interface SubProtocolErrorHandler<P> {
* @return the error message to send to the client, or {@code null} in which
* case no message will be sent.
*/
@Nullable
Message<P> handleErrorMessageToClient(Message<P> errorMessage);
@Nullable Message<P> handleErrorMessageToClient(Message<P> errorMessage);
}

View File

@@ -18,7 +18,8 @@ package org.springframework.web.socket.messaging;
import java.util.List;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.web.socket.CloseStatus;
@@ -67,8 +68,7 @@ public interface SubProtocolHandler {
* Resolve the session id from the given message or return {@code null}.
* @param message the message to resolve the session id from
*/
@Nullable
String resolveSessionId(Message<?> message);
@Nullable String resolveSessionId(Message<?> message);
/**
* Invoked after a {@link WebSocketSession} has started.

View File

@@ -30,9 +30,9 @@ import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.context.SmartLifecycle;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
@@ -86,8 +86,7 @@ public class SubProtocolWebSocketHandler
private final Set<SubProtocolHandler> protocolHandlers = new LinkedHashSet<>();
@Nullable
private SubProtocolHandler defaultProtocolHandler;
private @Nullable SubProtocolHandler defaultProtocolHandler;
private final Map<String, WebSocketSessionHolder> sessions = new ConcurrentHashMap<>();
@@ -103,8 +102,7 @@ public class SubProtocolWebSocketHandler
private final DefaultStats stats = new DefaultStats();
@Nullable
private Integer phase;
private @Nullable Integer phase;
private volatile boolean running;
@@ -184,8 +182,7 @@ public class SubProtocolWebSocketHandler
/**
* Return the default sub-protocol handler to use.
*/
@Nullable
public SubProtocolHandler getDefaultProtocolHandler() {
public @Nullable SubProtocolHandler getDefaultProtocolHandler() {
return this.defaultProtocolHandler;
}
@@ -477,8 +474,7 @@ public class SubProtocolWebSocketHandler
return handler;
}
@Nullable
private String resolveSessionId(Message<?> message) {
private @Nullable String resolveSessionId(Message<?> message) {
for (SubProtocolHandler handler : this.protocolHandlerLookup.values()) {
String sessionId = handler.resolveSessionId(message);
if (sessionId != null) {

View File

@@ -19,8 +19,9 @@ package org.springframework.web.socket.messaging;
import java.util.ArrayList;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.context.ApplicationContext;
import org.springframework.lang.Nullable;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.messaging.handler.MessagingAdviceBean;
@@ -100,8 +101,7 @@ public class WebSocketAnnotationMethodMessageHandler extends SimpAnnotationMetho
}
@Override
@Nullable
public Class<?> getBeanType() {
public @Nullable Class<?> getBeanType() {
return this.adviceBean.getBeanType();
}

View File

@@ -29,10 +29,10 @@ import java.util.function.BiConsumer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
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;
@@ -81,8 +81,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
private int inboundMessageSizeLimit = 64 * 1024;
@Nullable
private Integer outboundMessageSizeLimit;
private @Nullable Integer outboundMessageSizeLimit;
private boolean autoStartup = true;
@@ -157,8 +156,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
* Get the configured outbound message buffer size in bytes.
* @since 6.2
*/
@Nullable
public Integer getOutboundMessageSizeLimit() {
public @Nullable Integer getOutboundMessageSizeLimit() {
return this.outboundMessageSizeLimit;
}
@@ -323,18 +321,15 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
private final StompWebSocketMessageCodec codec =
new StompWebSocketMessageCodec(getInboundMessageSizeLimit(),getOutboundMessageSizeLimit());
@Nullable
private volatile WebSocketSession session;
private volatile @Nullable WebSocketSession session;
private volatile long lastReadTime = -1;
private volatile long lastWriteTime = -1;
@Nullable
private ScheduledFuture<?> readInactivityFuture;
private @Nullable ScheduledFuture<?> readInactivityFuture;
@Nullable
private ScheduledFuture<?> writeInactivityFuture;
private @Nullable ScheduledFuture<?> writeInactivityFuture;
public WebSocketTcpConnectionHandlerAdapter(TcpConnectionHandler<byte[]> stompSession) {
Assert.notNull(stompSession, "TcpConnectionHandler must not be null");
@@ -516,8 +511,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
private final BufferingStompDecoder bufferingDecoder;
@Nullable
private final SplittingStompEncoder splittingEncoder;
private final @Nullable SplittingStompEncoder splittingEncoder;
public StompWebSocketMessageCodec(int inboundMessageSizeLimit, @Nullable Integer outboundMessageSizeLimit) {
this.bufferingDecoder = new BufferingStompDecoder(DECODER, inboundMessageSizeLimit);

View File

@@ -1,9 +1,7 @@
/**
* WebSocket integration for Spring's messaging module.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.messaging;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -1,9 +1,7 @@
/**
* Common abstractions and Spring configuration support for WebSocket applications.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -18,9 +18,10 @@ package org.springframework.web.socket.server;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.web.socket.WebSocketHandler;
/**

View File

@@ -20,9 +20,10 @@ import java.security.Principal;
import java.util.List;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.web.socket.WebSocketExtension;
import org.springframework.web.socket.WebSocketHandler;

View File

@@ -29,12 +29,12 @@ import jakarta.servlet.http.HttpServletResponse;
import org.eclipse.jetty.ee10.websocket.server.JettyWebSocketCreator;
import org.eclipse.jetty.ee10.websocket.server.JettyWebSocketServerContainer;
import org.eclipse.jetty.websocket.api.Configurable;
import org.jspecify.annotations.Nullable;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.context.ServletContextAware;
import org.springframework.web.socket.WebSocketExtension;
@@ -55,8 +55,7 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Serv
private static final String[] SUPPORTED_VERSIONS = new String[] {"13"};
@Nullable
private Consumer<Configurable> webSocketConfigurer;
private @Nullable Consumer<Configurable> webSocketConfigurer;
@Override

View File

@@ -1,9 +1,7 @@
/**
* Server-side support for the Jetty WebSocket API.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.server.jetty;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -1,9 +1,7 @@
/**
* Server-side abstractions for WebSocket interactions.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.server;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -27,11 +27,11 @@ import jakarta.websocket.DeploymentException;
import jakarta.websocket.server.ServerContainer;
import jakarta.websocket.server.ServerEndpoint;
import jakarta.websocket.server.ServerEndpointConfig;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.context.ApplicationContext;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.context.support.WebApplicationObjectSupport;
@@ -56,11 +56,9 @@ import org.springframework.web.context.support.WebApplicationObjectSupport;
public class ServerEndpointExporter extends WebApplicationObjectSupport
implements InitializingBean, SmartInitializingSingleton {
@Nullable
private List<Class<?>> annotatedEndpointClasses;
private @Nullable List<Class<?>> annotatedEndpointClasses;
@Nullable
private ServerContainer serverContainer;
private @Nullable ServerContainer serverContainer;
/**
@@ -84,8 +82,7 @@ public class ServerEndpointExporter extends WebApplicationObjectSupport
/**
* Return the JSR-356 {@link ServerContainer} to use for endpoint registration.
*/
@Nullable
protected ServerContainer getServerContainer() {
protected @Nullable ServerContainer getServerContainer() {
return this.serverContainer;
}

View File

@@ -28,10 +28,10 @@ import jakarta.websocket.Extension;
import jakarta.websocket.HandshakeResponse;
import jakarta.websocket.server.HandshakeRequest;
import jakarta.websocket.server.ServerEndpointConfig;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.socket.handler.BeanCreatingHandlerProvider;
@@ -59,11 +59,9 @@ public class ServerEndpointRegistration extends ServerEndpointConfig.Configurato
private final String path;
@Nullable
private final Endpoint endpoint;
private final @Nullable Endpoint endpoint;
@Nullable
private final BeanCreatingHandlerProvider<Endpoint> endpointProvider;
private final @Nullable BeanCreatingHandlerProvider<Endpoint> endpointProvider;
private List<String> subprotocols = new ArrayList<>(0);

View File

@@ -19,10 +19,10 @@ package org.springframework.web.socket.server.standard;
import jakarta.servlet.ServletContext;
import jakarta.websocket.WebSocketContainer;
import jakarta.websocket.server.ServerContainer;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.context.ServletContextAware;
@@ -47,63 +47,53 @@ import org.springframework.web.context.ServletContextAware;
public class ServletServerContainerFactoryBean
implements FactoryBean<WebSocketContainer>, ServletContextAware, InitializingBean {
@Nullable
private Long asyncSendTimeout;
private @Nullable Long asyncSendTimeout;
@Nullable
private Long maxSessionIdleTimeout;
private @Nullable Long maxSessionIdleTimeout;
@Nullable
private Integer maxTextMessageBufferSize;
private @Nullable Integer maxTextMessageBufferSize;
@Nullable
private Integer maxBinaryMessageBufferSize;
private @Nullable Integer maxBinaryMessageBufferSize;
@Nullable
private ServletContext servletContext;
private @Nullable ServletContext servletContext;
@Nullable
private ServerContainer serverContainer;
private @Nullable ServerContainer serverContainer;
public void setAsyncSendTimeout(Long timeoutInMillis) {
public void setAsyncSendTimeout(@Nullable Long timeoutInMillis) {
this.asyncSendTimeout = timeoutInMillis;
}
@Nullable
public Long getAsyncSendTimeout() {
public @Nullable Long getAsyncSendTimeout() {
return this.asyncSendTimeout;
}
public void setMaxSessionIdleTimeout(Long timeoutInMillis) {
public void setMaxSessionIdleTimeout(@Nullable Long timeoutInMillis) {
this.maxSessionIdleTimeout = timeoutInMillis;
}
@Nullable
public Long getMaxSessionIdleTimeout() {
public @Nullable Long getMaxSessionIdleTimeout() {
return this.maxSessionIdleTimeout;
}
public void setMaxTextMessageBufferSize(Integer bufferSize) {
public void setMaxTextMessageBufferSize(@Nullable Integer bufferSize) {
this.maxTextMessageBufferSize = bufferSize;
}
@Nullable
public Integer getMaxTextMessageBufferSize() {
public @Nullable Integer getMaxTextMessageBufferSize() {
return this.maxTextMessageBufferSize;
}
public void setMaxBinaryMessageBufferSize(Integer bufferSize) {
public void setMaxBinaryMessageBufferSize(@Nullable Integer bufferSize) {
this.maxBinaryMessageBufferSize = bufferSize;
}
@Nullable
public Integer getMaxBinaryMessageBufferSize() {
public @Nullable Integer getMaxBinaryMessageBufferSize() {
return this.maxBinaryMessageBufferSize;
}
@Override
public void setServletContext(ServletContext servletContext) {
public void setServletContext(@Nullable ServletContext servletContext) {
this.servletContext = servletContext;
}
@@ -133,8 +123,7 @@ public class ServletServerContainerFactoryBean
@Override
@Nullable
public ServerContainer getObject() {
public @Nullable ServerContainer getObject() {
return this.serverContainer;
}

View File

@@ -24,9 +24,9 @@ import jakarta.websocket.server.ServerEndpoint;
import jakarta.websocket.server.ServerEndpointConfig.Configurator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
@@ -98,8 +98,7 @@ public class SpringConfigurator extends Configurator {
return wac.getAutowireCapableBeanFactory().createBean(endpointClass);
}
@Nullable
private String getBeanNameByType(WebApplicationContext wac, Class<?> endpointClass) {
private @Nullable String getBeanNameByType(WebApplicationContext wac, Class<?> endpointClass) {
String wacId = wac.getId();
Map<Class<?>, String> beanNamesByType = cache.computeIfAbsent(wacId, k -> new ConcurrentHashMap<>());

View File

@@ -29,13 +29,13 @@ import jakarta.servlet.http.HttpServletResponse;
import jakarta.websocket.Extension;
import jakarta.websocket.WebSocketContainer;
import jakarta.websocket.server.ServerContainer;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.socket.WebSocketExtension;
import org.springframework.web.socket.WebSocketHandler;
@@ -63,8 +63,7 @@ public class StandardWebSocketUpgradeStrategy implements RequestUpgradeStrategy
private static final String[] SUPPORTED_VERSIONS = new String[] {"13"};
@Nullable
private volatile List<WebSocketExtension> extensions;
private volatile @Nullable List<WebSocketExtension> extensions;
@Override

View File

@@ -1,9 +1,7 @@
/**
* Server-side classes for use with standard JSR-356 WebSocket endpoints.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.server.standard;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -28,6 +28,7 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.context.Lifecycle;
import org.springframework.core.log.LogFormatUtils;
@@ -35,7 +36,6 @@ import org.springframework.http.HttpMethod;
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.util.StringUtils;
import org.springframework.web.socket.SubProtocolCapable;
@@ -285,8 +285,7 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
* @return the selected protocols or {@code null}
* @see #determineHandlerSupportedProtocols(WebSocketHandler)
*/
@Nullable
protected String selectProtocol(List<String> requestedProtocols, WebSocketHandler webSocketHandler) {
protected @Nullable String selectProtocol(List<String> requestedProtocols, WebSocketHandler webSocketHandler) {
List<String> handlerProtocols = determineHandlerSupportedProtocols(webSocketHandler);
for (String protocol : requestedProtocols) {
if (handlerProtocols.contains(protocol.toLowerCase(Locale.ROOT))) {
@@ -346,8 +345,7 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
* @param attributes handshake attributes to pass to the WebSocket session
* @return the user for the WebSocket session, or {@code null} if not available
*/
@Nullable
protected Principal determineUser(
protected @Nullable Principal determineUser(
ServerHttpRequest request, WebSocketHandler wsHandler, Map<String, Object> attributes) {
return request.getPrincipal();

View File

@@ -22,10 +22,10 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.HandshakeInterceptor;

View File

@@ -22,11 +22,11 @@ import java.util.Enumeration;
import java.util.Map;
import jakarta.servlet.http.HttpSession;
import org.jspecify.annotations.Nullable;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.lang.Nullable;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.server.HandshakeInterceptor;
@@ -162,8 +162,7 @@ public class HttpSessionHandshakeInterceptor implements HandshakeInterceptor {
return true;
}
@Nullable
private HttpSession getSession(ServerHttpRequest request) {
private @Nullable HttpSession getSession(ServerHttpRequest request) {
if (request instanceof ServletServerHttpRequest serverRequest) {
return serverRequest.getServletRequest().getSession(isCreateSession());
}

View File

@@ -25,11 +25,11 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
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.util.CollectionUtils;
import org.springframework.web.cors.CorsConfiguration;

View File

@@ -18,12 +18,12 @@ package org.springframework.web.socket.server.support;
import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletRequest;
import org.jspecify.annotations.Nullable;
import org.springframework.context.Lifecycle;
import org.springframework.context.SmartLifecycle;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.lang.Nullable;
import org.springframework.web.context.ServletContextAware;
import org.springframework.web.servlet.HandlerExecutionChain;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
@@ -41,8 +41,7 @@ public class WebSocketHandlerMapping extends SimpleUrlHandlerMapping implements
private boolean webSocketUpgradeMatch;
@Nullable
private Integer phase;
private @Nullable Integer phase;
private volatile boolean running;
@@ -118,8 +117,7 @@ public class WebSocketHandlerMapping extends SimpleUrlHandlerMapping implements
@Override
@Nullable
protected Object getHandlerInternal(HttpServletRequest request) throws Exception {
protected @Nullable Object getHandlerInternal(HttpServletRequest request) throws Exception {
Object handler = super.getHandlerInternal(request);
return (matchWebSocketUpgrade(handler, request) ? handler : null);
}

View File

@@ -28,13 +28,13 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.context.Lifecycle;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.context.ServletContextAware;

View File

@@ -2,9 +2,7 @@
* Server-side support classes including container-specific strategies
* for upgrading a request.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.server.support;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -16,8 +16,9 @@
package org.springframework.web.socket.sockjs;
import org.jspecify.annotations.Nullable;
import org.springframework.core.NestedRuntimeException;
import org.springframework.lang.Nullable;
/**
* Base class for exceptions raised while processing SockJS HTTP requests.
@@ -28,8 +29,7 @@ import org.springframework.lang.Nullable;
@SuppressWarnings("serial")
public class SockJsException extends NestedRuntimeException {
@Nullable
private final String sessionId;
private final @Nullable String sessionId;
/**
@@ -56,8 +56,7 @@ public class SockJsException extends NestedRuntimeException {
/**
* Return the SockJS session id.
*/
@Nullable
public String getSockJsSessionId() {
public @Nullable String getSockJsSessionId() {
return this.sessionId;
}

View File

@@ -16,9 +16,10 @@
package org.springframework.web.socket.sockjs;
import org.jspecify.annotations.Nullable;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.handler.ExceptionWebSocketHandlerDecorator;

View File

@@ -16,7 +16,7 @@
package org.springframework.web.socket.sockjs;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* Indicates a serious failure that occurred in the SockJS implementation as opposed to

View File

@@ -25,9 +25,9 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
@@ -61,11 +61,9 @@ public abstract class AbstractClientSockJsSession implements WebSocketSession {
private final Map<String, Object> attributes = new ConcurrentHashMap<>();
@Nullable
private volatile State state = State.NEW;
private volatile @Nullable State state = State.NEW;
@Nullable
private volatile CloseStatus closeStatus;
private volatile @Nullable CloseStatus closeStatus;
protected AbstractClientSockJsSession(TransportRequest request, WebSocketHandler handler,
@@ -101,8 +99,7 @@ public abstract class AbstractClientSockJsSession implements WebSocketSession {
}
@Override
@Nullable
public Principal getPrincipal() {
public @Nullable Principal getPrincipal() {
return this.request.getUser();
}

View File

@@ -24,11 +24,11 @@ import java.util.concurrent.CompletableFuture;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.lang.Nullable;
import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketHandler;

View File

@@ -28,9 +28,9 @@ import java.util.function.BiConsumer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.util.Assert;
import org.springframework.web.socket.WebSocketHandler;
@@ -62,18 +62,15 @@ class DefaultTransportRequest implements TransportRequest {
private final SockJsMessageCodec codec;
@Nullable
private Principal user;
private @Nullable Principal user;
private long timeoutValue;
@Nullable
private TaskScheduler timeoutScheduler;
private @Nullable TaskScheduler timeoutScheduler;
private final List<Runnable> timeoutTasks = new ArrayList<>();
@Nullable
private DefaultTransportRequest fallbackRequest;
private @Nullable DefaultTransportRequest fallbackRequest;
public DefaultTransportRequest(SockJsUrlInfo sockJsUrlInfo,
@@ -118,8 +115,7 @@ class DefaultTransportRequest implements TransportRequest {
}
@Override
@Nullable
public Principal getUser() {
public @Nullable Principal getUser() {
return this.user;
}

View File

@@ -18,8 +18,9 @@ package org.springframework.web.socket.sockjs.client;
import java.net.URI;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
/**
* A component that can execute the SockJS "Info" request that needs to be

View File

@@ -29,12 +29,12 @@ import org.eclipse.jetty.client.Response;
import org.eclipse.jetty.client.StringRequestContent;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpMethod;
import org.jspecify.annotations.Nullable;
import org.springframework.context.Lifecycle;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StreamUtils;
import org.springframework.web.client.HttpServerErrorException;

View File

@@ -22,6 +22,8 @@ import java.io.InputStream;
import java.net.URI;
import java.util.concurrent.CompletableFuture;
import org.jspecify.annotations.Nullable;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.http.HttpHeaders;
@@ -32,7 +34,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.http.StreamingHttpOutputMessage;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StreamUtils;
import org.springframework.web.client.HttpServerErrorException;
@@ -167,8 +168,7 @@ public class RestTemplateXhrTransport extends AbstractXhrTransport {
private final HttpHeaders headers;
@Nullable
private final String body;
private final @Nullable String body;
public XhrRequestCallback(HttpHeaders headers) {
this(headers, null);
@@ -207,8 +207,7 @@ public class RestTemplateXhrTransport extends AbstractXhrTransport {
}
@Override
@Nullable
public Object extractData(ClientHttpResponse response) throws IOException {
public @Nullable Object extractData(ClientHttpResponse response) throws IOException {
HttpStatusCode httpStatus = response.getStatusCode();
if (httpStatus != HttpStatus.OK) {
throw new HttpServerErrorException(

View File

@@ -27,10 +27,10 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.context.Lifecycle;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -72,16 +72,13 @@ public class SockJsClient implements WebSocketClient, Lifecycle {
private final List<Transport> transports;
@Nullable
private String[] httpHeaderNames;
private String @Nullable [] httpHeaderNames;
private InfoReceiver infoReceiver;
@Nullable
private SockJsMessageCodec messageCodec;
private @Nullable SockJsMessageCodec messageCodec;
@Nullable
private TaskScheduler connectTimeoutScheduler;
private @Nullable TaskScheduler connectTimeoutScheduler;
private volatile boolean running;
@@ -125,7 +122,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle {
* headers (for example, auth headers) to be used for other HTTP requests.
* @param httpHeaderNames the HTTP header names
*/
public void setHttpHeaderNames(@Nullable String... httpHeaderNames) {
public void setHttpHeaderNames(String @Nullable ... httpHeaderNames) {
this.httpHeaderNames = httpHeaderNames;
}
@@ -133,8 +130,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle {
* The configured HTTP header names to be copied from the handshake
* headers and also included in other HTTP requests.
*/
@Nullable
public String[] getHttpHeaderNames() {
public String @Nullable [] getHttpHeaderNames() {
return this.httpHeaderNames;
}
@@ -268,8 +264,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle {
return new SockJsUrlInfo(url);
}
@Nullable
private HttpHeaders getHttpRequestHeaders(@Nullable HttpHeaders webSocketHttpHeaders) {
private @Nullable HttpHeaders getHttpRequestHeaders(@Nullable HttpHeaders webSocketHttpHeaders) {
if (getHttpHeaderNames() == null || webSocketHttpHeaders == null) {
return webSocketHttpHeaders;
}
@@ -335,8 +330,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle {
* <p>By default this method returns {@code null}.
* @return the user to associate with the session (possibly {@code null})
*/
@Nullable
protected Principal getUser() {
protected @Nullable Principal getUser() {
return null;
}

View File

@@ -19,7 +19,8 @@ package org.springframework.web.socket.sockjs.client;
import java.net.URI;
import java.util.UUID;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.util.IdGenerator;
import org.springframework.util.JdkIdGenerator;
import org.springframework.util.StringUtils;
@@ -42,14 +43,11 @@ public class SockJsUrlInfo {
private final URI sockJsUrl;
@Nullable
private String serverId;
private @Nullable String serverId;
@Nullable
private String sessionId;
private @Nullable String sessionId;
@Nullable
private UUID uuid;
private @Nullable UUID uuid;
/**

View File

@@ -19,8 +19,9 @@ package org.springframework.web.socket.sockjs.client;
import java.net.URI;
import java.security.Principal;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
import org.springframework.web.socket.sockjs.frame.SockJsMessageCodec;
/**
@@ -63,8 +64,7 @@ public interface TransportRequest {
/**
* Return the user associated with the request, if any.
*/
@Nullable
Principal getUser();
@Nullable Principal getUser();
/**
* Return the message codec to use for encoding SockJS messages.

View File

@@ -39,6 +39,7 @@ import io.undertow.util.HeaderMap;
import io.undertow.util.HttpString;
import io.undertow.util.Methods;
import io.undertow.util.StringReadChannelListener;
import org.jspecify.annotations.Nullable;
import org.xnio.ChannelListener;
import org.xnio.ChannelListeners;
import org.xnio.IoUtils;
@@ -52,7 +53,6 @@ import org.xnio.channels.StreamSourceChannel;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StreamUtils;
import org.springframework.util.StringUtils;

View File

@@ -21,7 +21,8 @@ import java.net.InetSocketAddress;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
@@ -39,8 +40,7 @@ import org.springframework.web.socket.adapter.NativeWebSocketSession;
*/
public class WebSocketClientSockJsSession extends AbstractClientSockJsSession implements NativeWebSocketSession {
@Nullable
private WebSocketSession webSocketSession;
private @Nullable WebSocketSession webSocketSession;
public WebSocketClientSockJsSession(TransportRequest request, WebSocketHandler handler,
@@ -58,28 +58,24 @@ public class WebSocketClientSockJsSession extends AbstractClientSockJsSession im
@SuppressWarnings("unchecked")
@Override
@Nullable
public <T> T getNativeSession(@Nullable Class<T> requiredType) {
public <T> @Nullable T getNativeSession(@Nullable Class<T> requiredType) {
return (requiredType == null || requiredType.isInstance(this.webSocketSession) ? (T) this.webSocketSession : null);
}
@Override
@Nullable
public InetSocketAddress getLocalAddress() {
public @Nullable InetSocketAddress getLocalAddress() {
Assert.state(this.webSocketSession != null, "WebSocketSession not yet initialized");
return this.webSocketSession.getLocalAddress();
}
@Override
@Nullable
public InetSocketAddress getRemoteAddress() {
public @Nullable InetSocketAddress getRemoteAddress() {
Assert.state(this.webSocketSession != null, "WebSocketSession not yet initialized");
return this.webSocketSession.getRemoteAddress();
}
@Override
@Nullable
public String getAcceptedProtocol() {
public @Nullable String getAcceptedProtocol() {
Assert.state(this.webSocketSession != null, "WebSocketSession not yet initialized");
return this.webSocketSession.getAcceptedProtocol();
}

View File

@@ -22,9 +22,10 @@ import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
@@ -78,21 +79,18 @@ public class XhrClientSockJsSession extends AbstractClientSockJsSession {
}
@Override
@Nullable
public InetSocketAddress getLocalAddress() {
public @Nullable InetSocketAddress getLocalAddress() {
return null;
}
@Override
@Nullable
public InetSocketAddress getRemoteAddress() {
public @Nullable InetSocketAddress getRemoteAddress() {
URI uri = getUri();
return (uri != null ? new InetSocketAddress(uri.getHost(), uri.getPort()) : null);
}
@Override
@Nullable
public String getAcceptedProtocol() {
public @Nullable String getAcceptedProtocol() {
return null;
}

View File

@@ -2,9 +2,7 @@
* SockJS client implementation of
* {@link org.springframework.web.socket.client.WebSocketClient}.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.sockjs.client;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -23,9 +23,9 @@ import com.fasterxml.jackson.core.io.JsonStringEncoder;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.jspecify.annotations.Nullable;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -56,14 +56,12 @@ public class Jackson2SockJsMessageCodec extends AbstractSockJsMessageCodec {
@Override
@Nullable
public String[] decode(String content) throws IOException {
public String @Nullable [] decode(String content) throws IOException {
return this.objectMapper.readValue(content, String[].class);
}
@Override
@Nullable
public String[] decodeInputStream(InputStream content) throws IOException {
public String @Nullable [] decodeInputStream(InputStream content) throws IOException {
return this.objectMapper.readValue(content, String[].class);
}

View File

@@ -19,7 +19,8 @@ package org.springframework.web.socket.sockjs.frame;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -109,8 +110,7 @@ public class SockJsFrame {
* for SockJS "open" and "close" frames, which do not contain data, return
* {@code null}.
*/
@Nullable
public String getFrameData() {
public @Nullable String getFrameData() {
if (getType() == SockJsFrameType.OPEN || getType() == SockJsFrameType.HEARTBEAT) {
return null;
}

View File

@@ -19,7 +19,7 @@ package org.springframework.web.socket.sockjs.frame;
import java.io.IOException;
import java.io.InputStream;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* Encode and decode messages to and from a SockJS message frame,
@@ -50,8 +50,7 @@ public interface SockJsMessageCodec {
* @return an array of messages, or {@code null} if none
* @throws IOException if the content could not be parsed
*/
@Nullable
String[] decode(String content) throws IOException;
String @Nullable [] decode(String content) throws IOException;
/**
* Decode the given SockJS message frame.
@@ -59,7 +58,6 @@ public interface SockJsMessageCodec {
* @return an array of messages, or {@code null} if none
* @throws IOException if the content could not be parsed
*/
@Nullable
String[] decodeInputStream(InputStream content) throws IOException;
String @Nullable [] decodeInputStream(InputStream content) throws IOException;
}

View File

@@ -2,9 +2,7 @@
* Support classes for creating SockJS frames including the encoding and decoding
* of SockJS message frames.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.sockjs.frame;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -1,9 +1,7 @@
/**
* Top-level SockJS types.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.socket.sockjs;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.core.log.LogFormatUtils;
import org.springframework.http.HttpHeaders;
@@ -40,7 +41,6 @@ import org.springframework.http.InvalidMediaTypeException;
import org.springframework.http.MediaType;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -342,8 +342,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
* @since 4.1.2
*/
@SuppressWarnings("ConstantConditions")
@Nullable
public Collection<String> getAllowedOrigins() {
public @Nullable Collection<String> getAllowedOrigins() {
return this.corsConfiguration.getAllowedOrigins();
}
/**
@@ -365,8 +364,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
* @since 5.3.2
*/
@SuppressWarnings("ConstantConditions")
@Nullable
public Collection<String> getAllowedOriginPatterns() {
public @Nullable Collection<String> getAllowedOriginPatterns() {
return this.corsConfiguration.getAllowedOriginPatterns();
}
@@ -542,8 +540,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
}
@Override
@Nullable
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
public @Nullable CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
if (!this.suppressCors && (request.getHeader(HttpHeaders.ORIGIN) != null)) {
return this.corsConfiguration;
}

Some files were not shown because too many files have changed in this diff Show More