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

@@ -37,6 +37,7 @@ 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.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.BeanInitializationException;
@@ -52,7 +53,6 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.server.RequestPath;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.context.WebApplicationContext;
@@ -289,8 +289,7 @@ public class DispatcherServlet extends FrameworkServlet {
protected static final Log pageNotFoundLogger = LogFactory.getLog(PAGE_NOT_FOUND_LOG_CATEGORY);
/** Store default strategy implementations. */
@Nullable
private static Properties defaultStrategies;
private static @Nullable Properties defaultStrategies;
/** Detect all HandlerMappings or just expect "handlerMapping" bean?. */
private boolean detectAllHandlerMappings = true;
@@ -308,41 +307,32 @@ public class DispatcherServlet extends FrameworkServlet {
private boolean cleanupAfterInclude = true;
/** MultipartResolver used by this servlet. */
@Nullable
private MultipartResolver multipartResolver;
private @Nullable MultipartResolver multipartResolver;
/** LocaleResolver used by this servlet. */
@Nullable
private LocaleResolver localeResolver;
private @Nullable LocaleResolver localeResolver;
/** ThemeResolver used by this servlet. */
@Deprecated
@Nullable
private ThemeResolver themeResolver;
private @Nullable ThemeResolver themeResolver;
/** List of HandlerMappings used by this servlet. */
@Nullable
private List<HandlerMapping> handlerMappings;
private @Nullable List<HandlerMapping> handlerMappings;
/** List of HandlerAdapters used by this servlet. */
@Nullable
private List<HandlerAdapter> handlerAdapters;
private @Nullable List<HandlerAdapter> handlerAdapters;
/** List of HandlerExceptionResolvers used by this servlet. */
@Nullable
private List<HandlerExceptionResolver> handlerExceptionResolvers;
private @Nullable List<HandlerExceptionResolver> handlerExceptionResolvers;
/** RequestToViewNameTranslator used by this servlet. */
@Nullable
private RequestToViewNameTranslator viewNameTranslator;
private @Nullable RequestToViewNameTranslator viewNameTranslator;
/** FlashMapManager used by this servlet. */
@Nullable
private FlashMapManager flashMapManager;
private @Nullable FlashMapManager flashMapManager;
/** List of ViewResolvers used by this servlet. */
@Nullable
private List<ViewResolver> viewResolvers;
private @Nullable List<ViewResolver> viewResolvers;
private boolean parseRequestPath;
@@ -791,8 +781,7 @@ public class DispatcherServlet extends FrameworkServlet {
* @see #getWebApplicationContext()
*/
@Deprecated
@Nullable
public final org.springframework.ui.context.ThemeSource getThemeSource() {
public final org.springframework.ui.context.@Nullable ThemeSource getThemeSource() {
return (getWebApplicationContext() instanceof org.springframework.ui.context.ThemeSource themeSource ?
themeSource : null);
}
@@ -802,8 +791,7 @@ public class DispatcherServlet extends FrameworkServlet {
* @return the MultipartResolver used by this servlet, or {@code null} if none
* (indicating that no multipart support is available)
*/
@Nullable
public final MultipartResolver getMultipartResolver() {
public final @Nullable MultipartResolver getMultipartResolver() {
return this.multipartResolver;
}
@@ -817,8 +805,7 @@ public class DispatcherServlet extends FrameworkServlet {
* if not initialized yet
* @since 5.0
*/
@Nullable
public final List<HandlerMapping> getHandlerMappings() {
public final @Nullable List<HandlerMapping> getHandlerMappings() {
return (this.handlerMappings != null ? Collections.unmodifiableList(this.handlerMappings) : null);
}
@@ -1253,8 +1240,7 @@ public class DispatcherServlet extends FrameworkServlet {
* @param request current HTTP request
* @return the HandlerExecutionChain, or {@code null} if no handler could be found
*/
@Nullable
protected HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
protected @Nullable HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
if (this.handlerMappings != null) {
for (HandlerMapping mapping : this.handlerMappings) {
HandlerExecutionChain handler = mapping.getHandler(request);
@@ -1307,8 +1293,7 @@ public class DispatcherServlet extends FrameworkServlet {
* @return a corresponding ModelAndView to forward to
* @throws Exception if no error ModelAndView found
*/
@Nullable
protected ModelAndView processHandlerException(HttpServletRequest request, HttpServletResponse response,
protected @Nullable ModelAndView processHandlerException(HttpServletRequest request, HttpServletResponse response,
@Nullable Object handler, Exception ex) throws Exception {
// Success and error responses may use different content types
@@ -1420,8 +1405,7 @@ public class DispatcherServlet extends FrameworkServlet {
* @return the view name (or {@code null} if no default found)
* @throws Exception if view name translation failed
*/
@Nullable
protected String getDefaultViewName(HttpServletRequest request) throws Exception {
protected @Nullable String getDefaultViewName(HttpServletRequest request) throws Exception {
return (this.viewNameTranslator != null ? this.viewNameTranslator.getViewName(request) : null);
}
@@ -1439,15 +1423,13 @@ public class DispatcherServlet extends FrameworkServlet {
* (typically in case of problems creating an actual View object)
* @see ViewResolver#resolveViewName
*/
@Nullable
protected View resolveViewName(String viewName, @Nullable Map<String, Object> model,
protected @Nullable View resolveViewName(String viewName, @Nullable Map<String, Object> model,
Locale locale, HttpServletRequest request) throws Exception {
return resolveViewNameInternal(viewName, locale);
}
@Nullable
private View resolveViewNameInternal(String viewName, Locale locale) throws Exception {
private @Nullable View resolveViewNameInternal(String viewName, Locale locale) throws Exception {
if (this.viewResolvers != null) {
for (ViewResolver viewResolver : this.viewResolvers) {
View view = viewResolver.resolveViewName(viewName, locale);

View File

@@ -18,7 +18,8 @@ package org.springframework.web.servlet;
import java.util.HashMap;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.ObjectUtils;
@@ -49,8 +50,7 @@ import org.springframework.util.StringUtils;
@SuppressWarnings("serial")
public final class FlashMap extends HashMap<String, Object> implements Comparable<FlashMap> {
@Nullable
private String targetRequestPath;
private @Nullable String targetRequestPath;
private final MultiValueMap<String, String> targetRequestParams = new LinkedMultiValueMap<>(3);
@@ -69,8 +69,7 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
/**
* Return the target URL path (or {@code null} if none specified).
*/
@Nullable
public String getTargetRequestPath() {
public @Nullable String getTargetRequestPath() {
return this.targetRequestPath;
}

View File

@@ -18,8 +18,7 @@ package org.springframework.web.servlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* A strategy interface for retrieving and saving FlashMap instances.
@@ -42,8 +41,7 @@ public interface FlashMapManager {
* @param response the current response
* @return a FlashMap matching the current request or {@code null}
*/
@Nullable
FlashMap retrieveAndUpdate(HttpServletRequest request, HttpServletResponse response);
@Nullable FlashMap retrieveAndUpdate(HttpServletRequest request, HttpServletResponse response);
/**
* Save the given FlashMap, in some underlying storage and set the start

View File

@@ -31,6 +31,7 @@ import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponseWrapper;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
@@ -50,7 +51,6 @@ import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatusCode;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@@ -176,31 +176,26 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
/** ServletContext attribute to find the WebApplicationContext in. */
@Nullable
private String contextAttribute;
private @Nullable String contextAttribute;
/** WebApplicationContext implementation class to create. */
private Class<?> contextClass = DEFAULT_CONTEXT_CLASS;
/** WebApplicationContext id to assign. */
@Nullable
private String contextId;
private @Nullable String contextId;
/** Namespace for this servlet. */
@Nullable
private String namespace;
private @Nullable String namespace;
/** Explicit context config location. */
@Nullable
private String contextConfigLocation;
private @Nullable String contextConfigLocation;
/** Actual ApplicationContextInitializer instances to apply to the context. */
private final List<ApplicationContextInitializer<ConfigurableApplicationContext>> contextInitializers =
new ArrayList<>();
/** Comma-delimited ApplicationContextInitializer class names set through init param. */
@Nullable
private String contextInitializerClasses;
private @Nullable String contextInitializerClasses;
/** Should we publish the context as a ServletContext attribute?. */
private boolean publishContext = true;
@@ -221,8 +216,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
private boolean enableLoggingRequestDetails = false;
/** WebApplicationContext for this servlet. */
@Nullable
private WebApplicationContext webApplicationContext;
private @Nullable WebApplicationContext webApplicationContext;
/** If the WebApplicationContext was injected via {@link #setApplicationContext}. */
private boolean webApplicationContextInjected = false;
@@ -311,8 +305,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
* Return the name of the ServletContext attribute which should be used to retrieve the
* {@link WebApplicationContext} that this servlet is supposed to use.
*/
@Nullable
public String getContextAttribute() {
public @Nullable String getContextAttribute() {
return this.contextAttribute;
}
@@ -347,8 +340,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
/**
* Return the custom WebApplicationContext id, if any.
*/
@Nullable
public String getContextId() {
public @Nullable String getContextId() {
return this.contextId;
}
@@ -380,8 +372,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
/**
* Return the explicit context config location, if any.
*/
@Nullable
public String getContextConfigLocation() {
public @Nullable String getContextConfigLocation() {
return this.contextConfigLocation;
}
@@ -392,7 +383,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
* @see #applyInitializers
*/
@SuppressWarnings("unchecked")
public void setContextInitializers(@Nullable ApplicationContextInitializer<?>... initializers) {
public void setContextInitializers(ApplicationContextInitializer<?> @Nullable ... initializers) {
if (initializers != null) {
for (ApplicationContextInitializer<?> initializer : initializers) {
this.contextInitializers.add((ApplicationContextInitializer<ConfigurableApplicationContext>) initializer);
@@ -623,8 +614,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
* @return the WebApplicationContext for this servlet, or {@code null} if not found
* @see #getContextAttribute()
*/
@Nullable
protected WebApplicationContext findWebApplicationContext() {
protected @Nullable WebApplicationContext findWebApplicationContext() {
String attrName = getContextAttribute();
if (attrName == null) {
return null;
@@ -805,8 +795,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
/**
* Return this servlet's WebApplicationContext.
*/
@Nullable
public final WebApplicationContext getWebApplicationContext() {
public final @Nullable WebApplicationContext getWebApplicationContext() {
return this.webApplicationContext;
}
@@ -1039,8 +1028,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
* @return the corresponding LocaleContext, or {@code null} if none to bind
* @see LocaleContextHolder#setLocaleContext
*/
@Nullable
protected LocaleContext buildLocaleContext(HttpServletRequest request) {
protected @Nullable LocaleContext buildLocaleContext(HttpServletRequest request) {
return new SimpleLocaleContext(request.getLocale());
}
@@ -1055,8 +1043,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
* the previously bound instance (or not binding any, if none bound before)
* @see RequestContextHolder#setRequestAttributes
*/
@Nullable
protected ServletRequestAttributes buildRequestAttributes(HttpServletRequest request,
protected @Nullable ServletRequestAttributes buildRequestAttributes(HttpServletRequest request,
@Nullable HttpServletResponse response, @Nullable RequestAttributes previousAttributes) {
if (previousAttributes == null || previousAttributes instanceof ServletRequestAttributes) {
@@ -1162,8 +1149,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
* @return the username, or {@code null} if none found
* @see jakarta.servlet.http.HttpServletRequest#getUserPrincipal()
*/
@Nullable
protected String getUsernameForRequest(HttpServletRequest request) {
protected @Nullable String getUsernameForRequest(HttpServletRequest request) {
Principal userPrincipal = request.getUserPrincipal();
return (userPrincipal != null ? userPrincipal.getName() : null);
}

View File

@@ -18,8 +18,7 @@ package org.springframework.web.servlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* MVC framework SPI, allowing parameterization of the core MVC workflow.
@@ -74,8 +73,7 @@ public interface HandlerAdapter {
* model data, or {@code null} if the request has been handled directly
* @throws Exception in case of errors
*/
@Nullable
ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception;
@Nullable ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception;
/**
* Same contract as for HttpServlet's {@code getLastModified} method.

View File

@@ -18,8 +18,7 @@ package org.springframework.web.servlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* Interface to be implemented by objects that can resolve exceptions thrown during
@@ -49,8 +48,7 @@ public interface HandlerExceptionResolver {
* @return a corresponding {@code ModelAndView} to forward to,
* or {@code null} for default processing in the resolution chain
*/
@Nullable
ModelAndView resolveException(
@Nullable ModelAndView resolveException(
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex);
}

View File

@@ -25,8 +25,8 @@ 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.lang.Nullable;
import org.springframework.util.CollectionUtils;
/**
@@ -62,7 +62,7 @@ public class HandlerExecutionChain {
* @param interceptors the array of interceptors to apply
* (in the given order) before the handler itself executes
*/
public HandlerExecutionChain(Object handler, @Nullable HandlerInterceptor... interceptors) {
public HandlerExecutionChain(Object handler, HandlerInterceptor @Nullable ... interceptors) {
this(handler, (interceptors != null ? Arrays.asList(interceptors) : Collections.emptyList()));
}
@@ -118,8 +118,7 @@ public class HandlerExecutionChain {
* Return the array of interceptors to apply (in the given order).
* @return the array of HandlerInterceptors instances (may be {@code null})
*/
@Nullable
public HandlerInterceptor[] getInterceptors() {
public HandlerInterceptor @Nullable [] getInterceptors() {
return (!this.interceptorList.isEmpty() ? this.interceptorList.toArray(new HandlerInterceptor[0]) : null);
}

View File

@@ -18,8 +18,8 @@ package org.springframework.web.servlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.web.method.HandlerMethod;
/**

View File

@@ -18,8 +18,7 @@ package org.springframework.web.servlet;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* Interface to be implemented by objects that define a mapping between
@@ -167,7 +166,6 @@ public interface HandlerMapping {
* any interceptors, or {@code null} if no mapping found
* @throws Exception if there is an internal error
*/
@Nullable
HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception;
@Nullable HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception;
}

View File

@@ -25,6 +25,7 @@ import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeansException;
@@ -39,7 +40,6 @@ import org.springframework.core.env.EnvironmentCapable;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceEditor;
import org.springframework.core.io.ResourceLoader;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@@ -84,8 +84,7 @@ public abstract class HttpServletBean extends HttpServlet implements Environment
/** Logger available to subclasses. */
protected final Log logger = LogFactory.getLog(getClass());
@Nullable
private ConfigurableEnvironment environment;
private @Nullable ConfigurableEnvironment environment;
private final Set<String> requiredProperties = new HashSet<>(4);
@@ -196,8 +195,7 @@ public abstract class HttpServletBean extends HttpServlet implements Environment
* @see #getServletConfig()
*/
@Override
@Nullable
public String getServletName() {
public @Nullable String getServletName() {
return (getServletConfig() != null ? getServletConfig().getServletName() : null);
}

View File

@@ -20,10 +20,10 @@ import java.util.Locale;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.context.i18n.LocaleContext;
import org.springframework.context.i18n.SimpleLocaleContext;
import org.springframework.lang.Nullable;
/**
* Extension of {@link LocaleResolver} that adds support for a rich locale context

View File

@@ -20,8 +20,7 @@ import java.util.Locale;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* Interface for web-based locale resolution strategies that allows for

View File

@@ -18,8 +18,9 @@ package org.springframework.web.servlet;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpStatusCode;
import org.springframework.lang.Nullable;
import org.springframework.ui.ModelMap;
import org.springframework.util.CollectionUtils;
@@ -47,16 +48,13 @@ import org.springframework.util.CollectionUtils;
public class ModelAndView {
/** View instance or view name String. */
@Nullable
private Object view;
private @Nullable Object view;
/** Model Map. */
@Nullable
private ModelMap model;
private @Nullable ModelMap model;
/** Optional HTTP status for the response. */
@Nullable
private HttpStatusCode status;
private @Nullable HttpStatusCode status;
/** Indicates whether this instance has been cleared with a call to {@link #clear()}. */
private boolean cleared = false;
@@ -193,8 +191,7 @@ public class ModelAndView {
* Return the view name to be resolved by the DispatcherServlet
* via a ViewResolver, or {@code null} if we are using a View object.
*/
@Nullable
public String getViewName() {
public @Nullable String getViewName() {
return (this.view instanceof String name ? name : null);
}
@@ -210,8 +207,7 @@ public class ModelAndView {
* Return the View object, or {@code null} if we are using a view name
* to be resolved by the DispatcherServlet via a ViewResolver.
*/
@Nullable
public View getView() {
public @Nullable View getView() {
return (this.view instanceof View v ? v : null);
}
@@ -236,8 +232,7 @@ public class ModelAndView {
* Return the model map. May return {@code null}.
* Called by DispatcherServlet for evaluation of the model.
*/
@Nullable
protected Map<String, Object> getModelInternal() {
protected @Nullable Map<String, Object> getModelInternal() {
return this.model;
}
@@ -272,8 +267,7 @@ public class ModelAndView {
* Return the configured HTTP status for the response, if any.
* @since 4.3
*/
@Nullable
public HttpStatusCode getStatus() {
public @Nullable HttpStatusCode getStatus() {
return this.status;
}

View File

@@ -17,8 +17,7 @@
package org.springframework.web.servlet;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* Strategy interface for translating an incoming
@@ -38,7 +37,6 @@ public interface RequestToViewNameTranslator {
* @return the view name, or {@code null} if no default found
* @throws Exception if view name translation fails
*/
@Nullable
String getViewName(HttpServletRequest request) throws Exception;
@Nullable String getViewName(HttpServletRequest request) throws Exception;
}

View File

@@ -18,8 +18,7 @@ package org.springframework.web.servlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* Interface for web-based theme resolution strategies that allows for

View File

@@ -20,8 +20,7 @@ import java.util.Map;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* MVC View for a web interaction. Implementations are responsible for rendering
@@ -78,8 +77,7 @@ public interface View {
* @return the content type String (optionally including a character set),
* or {@code null} if not predetermined
*/
@Nullable
default String getContentType() {
default @Nullable String getContentType() {
return null;
}

View File

@@ -18,7 +18,7 @@ package org.springframework.web.servlet;
import java.util.Locale;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* Interface to be implemented by objects that can resolve views by name.
@@ -52,7 +52,6 @@ public interface ViewResolver {
* @throws Exception if the view cannot be resolved
* (typically in case of problems creating an actual View object)
*/
@Nullable
View resolveViewName(String viewName, Locale locale) throws Exception;
@Nullable View resolveViewName(String viewName, Locale locale) throws Exception;
}

View File

@@ -22,6 +22,7 @@ import java.util.Properties;
import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.jspecify.annotations.Nullable;
import org.w3c.dom.Element;
import org.springframework.beans.factory.FactoryBean;
@@ -57,7 +58,6 @@ import org.springframework.http.converter.support.AllEncompassingFormHttpMessage
import org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter;
import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter;
import org.springframework.http.converter.yaml.MappingJackson2YamlHttpMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.xml.DomUtils;
@@ -196,8 +196,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext context) {
public @Nullable BeanDefinition parse(Element element, ParserContext context) {
Object source = context.extractSource(element);
XmlReaderContext readerContext = context.getReaderContext();
@@ -363,8 +362,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
return conversionServiceRef;
}
@Nullable
private RuntimeBeanReference getValidator(Element element, @Nullable Object source, ParserContext context) {
private @Nullable RuntimeBeanReference getValidator(Element element, @Nullable Object source, ParserContext context) {
if (element.hasAttribute("validator")) {
return new RuntimeBeanReference(element.getAttribute("validator"));
}
@@ -466,8 +464,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
return defaultMediaTypes;
}
@Nullable
private RuntimeBeanReference getMessageCodesResolver(Element element) {
private @Nullable RuntimeBeanReference getMessageCodesResolver(Element element) {
if (element.hasAttribute("message-codes-resolver")) {
return new RuntimeBeanReference(element.getAttribute("message-codes-resolver"));
}
@@ -476,14 +473,12 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
}
}
@Nullable
private String getAsyncTimeout(Element element) {
private @Nullable String getAsyncTimeout(Element element) {
Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support");
return (asyncElement != null ? asyncElement.getAttribute("default-timeout") : null);
}
@Nullable
private RuntimeBeanReference getAsyncExecutor(Element element) {
private @Nullable RuntimeBeanReference getAsyncExecutor(Element element) {
Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support");
if (asyncElement != null && asyncElement.hasAttribute("task-executor")) {
return new RuntimeBeanReference(asyncElement.getAttribute("task-executor"));
@@ -512,8 +507,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
return interceptors;
}
@Nullable
private ManagedList<?> getArgumentResolvers(Element element, ParserContext context) {
private @Nullable ManagedList<?> getArgumentResolvers(Element element, ParserContext context) {
Element resolversElement = DomUtils.getChildElementByTagName(element, "argument-resolvers");
if (resolversElement != null) {
ManagedList<Object> resolvers = extractBeanSubElements(resolversElement, context);
@@ -541,8 +535,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
return result;
}
@Nullable
private ManagedList<?> getReturnValueHandlers(Element element, ParserContext context) {
private @Nullable ManagedList<?> getReturnValueHandlers(Element element, ParserContext context) {
Element handlers = DomUtils.getChildElementByTagName(element, "return-value-handlers");
return (handlers != null ? extractBeanSubElements(handlers, context) : null);
}
@@ -660,14 +653,11 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
static class CompositeUriComponentsContributorFactoryBean
implements FactoryBean<CompositeUriComponentsContributor>, InitializingBean {
@Nullable
private RequestMappingHandlerAdapter handlerAdapter;
private @Nullable RequestMappingHandlerAdapter handlerAdapter;
@Nullable
private ConversionService conversionService;
private @Nullable ConversionService conversionService;
@Nullable
private CompositeUriComponentsContributor uriComponentsContributor;
private @Nullable CompositeUriComponentsContributor uriComponentsContributor;
public void setHandlerAdapter(RequestMappingHandlerAdapter handlerAdapter) {
this.handlerAdapter = handlerAdapter;
@@ -685,8 +675,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
}
@Override
@Nullable
public CompositeUriComponentsContributor getObject() {
public @Nullable CompositeUriComponentsContributor getObject() {
return this.uriComponentsContributor;
}

View File

@@ -21,12 +21,12 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.springframework.web.cors.CorsConfiguration;
@@ -43,8 +43,7 @@ import org.springframework.web.cors.CorsConfiguration;
public class CorsBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
public @Nullable BeanDefinition parse(Element element, ParserContext parserContext) {
Map<String, CorsConfiguration> corsConfigurations = new LinkedHashMap<>();
List<Element> mappings = DomUtils.getChildElementsByTagName(element, "mapping");

View File

@@ -18,6 +18,7 @@ package org.springframework.web.servlet.config;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -26,7 +27,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.StringUtils;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
@@ -45,8 +45,7 @@ import org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler
class DefaultServletHandlerBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
public @Nullable BeanDefinition parse(Element element, ParserContext parserContext) {
Object source = parserContext.extractSource(element);
String defaultServletName = element.getAttribute("default-servlet-name");

View File

@@ -18,6 +18,7 @@ package org.springframework.web.servlet.config;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -28,7 +29,6 @@ import org.springframework.beans.factory.support.ManagedList;
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.xml.DomUtils;
import org.springframework.web.servlet.handler.MappedInterceptor;
@@ -42,8 +42,7 @@ import org.springframework.web.servlet.handler.MappedInterceptor;
class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext context) {
public @Nullable BeanDefinition parse(Element element, ParserContext context) {
context.pushContainingComponent(
new CompositeComponentDefinition(element.getTagName(), context.extractSource(element)));

View File

@@ -19,6 +19,8 @@ package org.springframework.web.servlet.config;
import java.util.LinkedHashMap;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.RuntimeBeanReference;
@@ -26,7 +28,6 @@ import org.springframework.beans.factory.parsing.BeanComponentDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.lang.Nullable;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.Assert;
import org.springframework.util.PathMatcher;
@@ -114,8 +115,7 @@ public abstract class MvcNamespaceUtils {
* Return the {@link PathMatcher} bean definition if it has been registered
* in the context as an alias with its well-known name, or {@code null}.
*/
@Nullable
static RuntimeBeanReference getCustomPathMatcher(ParserContext context) {
static @Nullable RuntimeBeanReference getCustomPathMatcher(ParserContext context) {
if(context.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) {
return new RuntimeBeanReference(PATH_MATCHER_BEAN_NAME);
}
@@ -154,8 +154,7 @@ public abstract class MvcNamespaceUtils {
* Return the {@link PathPatternParser} bean definition if it has been registered
* in the context as an alias with its well-known name, or {@code null}.
*/
@Nullable
static RuntimeBeanReference getCustomPatternParser(ParserContext context) {
static @Nullable RuntimeBeanReference getCustomPatternParser(ParserContext context) {
if (context.getRegistry().isAlias(PATTERN_PARSER_BEAN_NAME)) {
return new RuntimeBeanReference(PATTERN_PARSER_BEAN_NAME);
}
@@ -356,8 +355,7 @@ public abstract class MvcNamespaceUtils {
* with the {@code annotation-driven} element.
* @return a bean definition, bean reference, or {@code null} if none defined
*/
@Nullable
public static Object getContentNegotiationManager(ParserContext context) {
public static @Nullable Object getContentNegotiationManager(ParserContext context) {
String name = AnnotationDrivenBeanDefinitionParser.HANDLER_MAPPING_BEAN_NAME;
if (context.getRegistry().containsBeanDefinition(name)) {
BeanDefinition handlerMappingBeanDef = context.getRegistry().getBeanDefinition(name);

View File

@@ -19,6 +19,7 @@ package org.springframework.web.servlet.config;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.jspecify.annotations.Nullable;
import org.w3c.dom.Element;
import org.springframework.beans.MutablePropertyValues;
@@ -34,7 +35,6 @@ import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.cache.concurrent.ConcurrentMapCache;
import org.springframework.core.Ordered;
import org.springframework.http.CacheControl;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
@@ -86,8 +86,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext context) {
public @Nullable BeanDefinition parse(Element element, ParserContext context) {
Object source = context.extractSource(element);
registerUrlProvider(context, source);
@@ -154,8 +153,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
}
}
@Nullable
private String registerResourceHandler(ParserContext context, Element element,
private @Nullable String registerResourceHandler(ParserContext context, Element element,
RuntimeBeanReference pathHelperRef, @Nullable Object source) {
String locationAttr = element.getAttribute("location");

View File

@@ -18,6 +18,7 @@ package org.springframework.web.servlet.config;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -28,7 +29,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.HttpStatusCode;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.springframework.web.servlet.view.RedirectView;
@@ -60,9 +60,8 @@ class ViewControllerBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
@SuppressWarnings("unchecked")
public BeanDefinition parse(Element element, ParserContext parserContext) {
public @Nullable BeanDefinition parse(Element element, ParserContext parserContext) {
Object source = parserContext.extractSource(element);
// Register SimpleUrlHandlerMapping for view controllers

View File

@@ -18,6 +18,7 @@ package org.springframework.web.servlet.config;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.w3c.dom.Element;
import org.springframework.beans.MutablePropertyValues;
@@ -29,7 +30,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.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.util.xml.DomUtils;
import org.springframework.web.servlet.view.BeanNameViewResolver;
import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
@@ -69,8 +69,7 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext context) {
public @Nullable BeanDefinition parse(Element element, ParserContext context) {
Object source = context.extractSource(element);
context.pushContainingComponent(new CompositeComponentDefinition(element.getTagName(), source));

View File

@@ -21,8 +21,9 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
import org.jspecify.annotations.Nullable;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.lang.Nullable;
import org.springframework.web.context.request.async.CallableProcessingInterceptor;
import org.springframework.web.context.request.async.DeferredResult;
import org.springframework.web.context.request.async.DeferredResultProcessingInterceptor;
@@ -35,11 +36,9 @@ import org.springframework.web.context.request.async.DeferredResultProcessingInt
*/
public class AsyncSupportConfigurer {
@Nullable
private AsyncTaskExecutor taskExecutor;
private @Nullable AsyncTaskExecutor taskExecutor;
@Nullable
private Long timeout;
private @Nullable Long timeout;
private final List<CallableProcessingInterceptor> callableInterceptors = new ArrayList<>();
@@ -101,13 +100,11 @@ public class AsyncSupportConfigurer {
}
@Nullable
protected AsyncTaskExecutor getTaskExecutor() {
protected @Nullable AsyncTaskExecutor getTaskExecutor() {
return this.taskExecutor;
}
@Nullable
protected Long getTimeout() {
protected @Nullable Long getTimeout() {
return this.timeout;
}

View File

@@ -22,10 +22,10 @@ import java.util.List;
import java.util.Map;
import jakarta.servlet.ServletContext;
import org.jspecify.annotations.Nullable;
import org.springframework.http.MediaType;
import org.springframework.http.MediaTypeFactory;
import org.springframework.lang.Nullable;
import org.springframework.web.accept.ContentNegotiationManager;
import org.springframework.web.accept.ContentNegotiationManagerFactoryBean;
import org.springframework.web.accept.ContentNegotiationStrategy;

View File

@@ -19,9 +19,9 @@ package org.springframework.web.servlet.config.annotation;
import java.util.Collections;
import jakarta.servlet.ServletContext;
import org.jspecify.annotations.Nullable;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
@@ -46,8 +46,7 @@ public class DefaultServletHandlerConfigurer {
private final ServletContext servletContext;
@Nullable
private DefaultServletHttpRequestHandler handler;
private @Nullable DefaultServletHttpRequestHandler handler;
/**
@@ -93,8 +92,7 @@ public class DefaultServletHandlerConfigurer {
* enabled.
* @since 4.3.12
*/
@Nullable
protected SimpleUrlHandlerMapping buildHandlerMapping() {
protected @Nullable SimpleUrlHandlerMapping buildHandlerMapping() {
if (this.handler == null) {
return null;
}

View File

@@ -18,11 +18,12 @@ package org.springframework.web.servlet.config.annotation;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.MessageCodesResolver;
import org.springframework.validation.Validator;
@@ -140,14 +141,12 @@ public class DelegatingWebMvcConfiguration extends WebMvcConfigurationSupport {
}
@Override
@Nullable
protected Validator getValidator() {
protected @Nullable Validator getValidator() {
return this.configurers.getValidator();
}
@Override
@Nullable
protected MessageCodesResolver getMessageCodesResolver() {
protected @Nullable MessageCodesResolver getMessageCodesResolver() {
return this.configurers.getMessageCodesResolver();
}

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.AntPathMatcher;
import org.springframework.util.Assert;
import org.springframework.util.PathMatcher;
@@ -41,14 +42,11 @@ public class InterceptorRegistration {
private final HandlerInterceptor interceptor;
@Nullable
private List<String> includePatterns;
private @Nullable List<String> includePatterns;
@Nullable
private List<String> excludePatterns;
private @Nullable List<String> excludePatterns;
@Nullable
private PathMatcher pathMatcher;
private @Nullable PathMatcher pathMatcher;
private int order = 0;

View File

@@ -20,7 +20,8 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Predicate;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;
import org.springframework.web.util.UrlPathHelper;
@@ -45,26 +46,19 @@ public class PathMatchConfigurer {
private boolean preferPathMatcher = false;
@Nullable
private PathPatternParser patternParser;
private @Nullable PathPatternParser patternParser;
@Nullable
private Map<String, Predicate<Class<?>>> pathPrefixes;
private @Nullable Map<String, Predicate<Class<?>>> pathPrefixes;
@Nullable
private UrlPathHelper urlPathHelper;
private @Nullable UrlPathHelper urlPathHelper;
@Nullable
private PathMatcher pathMatcher;
private @Nullable PathMatcher pathMatcher;
@Nullable
private PathPatternParser defaultPatternParser;
private @Nullable PathPatternParser defaultPatternParser;
@Nullable
private UrlPathHelper defaultUrlPathHelper;
private @Nullable UrlPathHelper defaultUrlPathHelper;
@Nullable
private PathMatcher defaultPathMatcher;
private @Nullable PathMatcher defaultPathMatcher;
/**
@@ -158,23 +152,19 @@ public class PathMatchConfigurer {
* Return the {@link PathPatternParser} to use, if configured.
* @since 5.3
*/
@Nullable
public PathPatternParser getPatternParser() {
public @Nullable PathPatternParser getPatternParser() {
return this.patternParser;
}
@Nullable
protected Map<String, Predicate<Class<?>>> getPathPrefixes() {
protected @Nullable Map<String, Predicate<Class<?>>> getPathPrefixes() {
return this.pathPrefixes;
}
@Nullable
public UrlPathHelper getUrlPathHelper() {
public @Nullable UrlPathHelper getUrlPathHelper() {
return this.urlPathHelper;
}
@Nullable
public PathMatcher getPathMatcher() {
public @Nullable PathMatcher getPathMatcher() {
return this.pathMatcher;
}

View File

@@ -16,9 +16,10 @@
package org.springframework.web.servlet.config.annotation;
import org.jspecify.annotations.Nullable;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatusCode;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.springframework.web.servlet.view.RedirectView;

View File

@@ -19,9 +19,10 @@ package org.springframework.web.servlet.config.annotation;
import java.util.ArrayList;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.cache.Cache;
import org.springframework.cache.concurrent.ConcurrentMapCache;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.web.servlet.resource.CachingResourceResolver;

View File

@@ -21,10 +21,11 @@ import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import org.jspecify.annotations.Nullable;
import org.springframework.cache.Cache;
import org.springframework.core.io.Resource;
import org.springframework.http.CacheControl;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.servlet.resource.PathResourceResolver;
@@ -46,19 +47,15 @@ public class ResourceHandlerRegistration {
private final List<Resource> locationsResources = new ArrayList<>();
@Nullable
private Integer cachePeriod;
private @Nullable Integer cachePeriod;
@Nullable
private CacheControl cacheControl;
private @Nullable CacheControl cacheControl;
@Nullable
private ResourceChainRegistration resourceChainRegistration;
private @Nullable ResourceChainRegistration resourceChainRegistration;
private boolean useLastModified = true;
@Nullable
private Function<Resource, String> etagGenerator;
private @Nullable Function<Resource, String> etagGenerator;
private boolean optimizeLocations = false;

View File

@@ -23,11 +23,11 @@ import java.util.List;
import java.util.Map;
import jakarta.servlet.ServletContext;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.context.ApplicationContext;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.Assert;
import org.springframework.web.HttpRequestHandler;
@@ -66,8 +66,7 @@ public class ResourceHandlerRegistry {
private final ApplicationContext applicationContext;
@Nullable
private final UrlPathHelper pathHelper;
private final @Nullable UrlPathHelper pathHelper;
private final List<ResourceHandlerRegistration> registrations = new ArrayList<>();
@@ -154,8 +153,7 @@ public class ResourceHandlerRegistry {
* Return a handler mapping with the mapped resource handlers; or {@code null} in case
* of no registrations.
*/
@Nullable
protected AbstractHandlerMapping getHandlerMapping() {
protected @Nullable AbstractHandlerMapping getHandlerMapping() {
if (this.registrations.isEmpty()) {
return null;
}

View File

@@ -16,9 +16,10 @@
package org.springframework.web.servlet.config.annotation;
import org.jspecify.annotations.Nullable;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatusCode;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.servlet.RequestToViewNameTranslator;
import org.springframework.web.servlet.mvc.ParameterizableViewController;

View File

@@ -21,9 +21,10 @@ 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.http.HttpStatusCode;
import org.springframework.lang.Nullable;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
import org.springframework.web.util.pattern.PathPattern;
@@ -38,8 +39,7 @@ import org.springframework.web.util.pattern.PathPattern;
*/
public class ViewControllerRegistry {
@Nullable
private final ApplicationContext applicationContext;
private final @Nullable ApplicationContext applicationContext;
private final List<ViewControllerRegistration> registrations = new ArrayList<>(4);
@@ -128,8 +128,7 @@ public class ViewControllerRegistry {
* controller mappings, or {@code null} for no registrations.
* @since 4.3.12
*/
@Nullable
protected SimpleUrlHandlerMapping buildHandlerMapping() {
protected @Nullable SimpleUrlHandlerMapping buildHandlerMapping() {
if (this.registrations.isEmpty() && this.redirectRegistrations.isEmpty()) {
return null;
}

View File

@@ -21,11 +21,12 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.context.ApplicationContext;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.accept.ContentNegotiationManager;
@@ -52,19 +53,15 @@ import org.springframework.web.servlet.view.script.ScriptTemplateViewResolver;
*/
public class ViewResolverRegistry {
@Nullable
private final ContentNegotiationManager contentNegotiationManager;
@Nullable
private final ApplicationContext applicationContext;
private final @Nullable ApplicationContext applicationContext;
@Nullable
private ContentNegotiatingViewResolver contentNegotiatingResolver;
private @Nullable ContentNegotiatingViewResolver contentNegotiatingResolver;
private final List<ViewResolver> viewResolvers = new ArrayList<>(4);
@Nullable
private Integer order;
private @Nullable Integer order;
/**

View File

@@ -24,6 +24,7 @@ import java.util.Locale;
import java.util.Map;
import jakarta.servlet.ServletContext;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.BeanInitializationException;
@@ -59,7 +60,6 @@ import org.springframework.http.converter.support.AllEncompassingFormHttpMessage
import org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter;
import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter;
import org.springframework.http.converter.yaml.MappingJackson2YamlHttpMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -233,38 +233,27 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
}
@Nullable
private ApplicationContext applicationContext;
private @Nullable ApplicationContext applicationContext;
@Nullable
private ServletContext servletContext;
private @Nullable ServletContext servletContext;
@Nullable
private List<Object> interceptors;
private @Nullable List<Object> interceptors;
@Nullable
private PathMatchConfigurer pathMatchConfigurer;
private @Nullable PathMatchConfigurer pathMatchConfigurer;
@Nullable
private ContentNegotiationManager contentNegotiationManager;
private @Nullable ContentNegotiationManager contentNegotiationManager;
@Nullable
private List<HandlerMethodArgumentResolver> argumentResolvers;
private @Nullable List<HandlerMethodArgumentResolver> argumentResolvers;
@Nullable
private List<HandlerMethodReturnValueHandler> returnValueHandlers;
private @Nullable List<HandlerMethodReturnValueHandler> returnValueHandlers;
@Nullable
private List<HttpMessageConverter<?>> messageConverters;
private @Nullable List<HttpMessageConverter<?>> messageConverters;
@Nullable
private List<ErrorResponse.Interceptor> errorResponseInterceptors;
private @Nullable List<ErrorResponse.Interceptor> errorResponseInterceptors;
@Nullable
private Map<String, CorsConfiguration> corsConfigurations;
private @Nullable Map<String, CorsConfiguration> corsConfigurations;
@Nullable
private AsyncSupportConfigurer asyncSupportConfigurer;
private @Nullable AsyncSupportConfigurer asyncSupportConfigurer;
/**
@@ -279,8 +268,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
* Return the associated Spring {@link ApplicationContext}.
* @since 4.2
*/
@Nullable
public final ApplicationContext getApplicationContext() {
public final @Nullable ApplicationContext getApplicationContext() {
return this.applicationContext;
}
@@ -297,8 +285,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
* Return the associated {@link jakarta.servlet.ServletContext}.
* @since 4.2
*/
@Nullable
public final ServletContext getServletContext() {
public final @Nullable ServletContext getServletContext() {
return this.servletContext;
}
@@ -475,8 +462,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
* {@link #addViewControllers}.
*/
@Bean
@Nullable
public HandlerMapping viewControllerHandlerMapping(
public @Nullable HandlerMapping viewControllerHandlerMapping(
@Qualifier("mvcConversionService") FormattingConversionService conversionService,
@Qualifier("mvcResourceUrlProvider") ResourceUrlProvider resourceUrlProvider) {
@@ -569,8 +555,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
* {@link #addResourceHandlers}.
*/
@Bean
@Nullable
public HandlerMapping resourceHandlerMapping(
public @Nullable HandlerMapping resourceHandlerMapping(
@Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager,
@Qualifier("mvcConversionService") FormattingConversionService conversionService,
@Qualifier("mvcResourceUrlProvider") ResourceUrlProvider resourceUrlProvider) {
@@ -614,8 +599,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
* override {@link #configureDefaultServletHandling}.
*/
@Bean
@Nullable
public HandlerMapping defaultServletHandlerMapping() {
public @Nullable HandlerMapping defaultServletHandlerMapping() {
Assert.state(this.servletContext != null, "No ServletContext set");
DefaultServletHandlerConfigurer configurer = new DefaultServletHandlerConfigurer(this.servletContext);
configureDefaultServletHandling(configurer);
@@ -716,8 +700,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
/**
* Override this method to provide a custom {@link MessageCodesResolver}.
*/
@Nullable
protected MessageCodesResolver getMessageCodesResolver() {
protected @Nullable MessageCodesResolver getMessageCodesResolver() {
return null;
}
@@ -770,8 +753,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
/**
* Override this method to provide a custom {@link Validator}.
*/
@Nullable
protected Validator getValidator() {
protected @Nullable Validator getValidator() {
return null;
}

View File

@@ -18,11 +18,12 @@ package org.springframework.web.servlet.config.annotation;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.Formatter;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.validation.MessageCodesResolver;
import org.springframework.validation.Validator;
import org.springframework.web.ErrorResponse;
@@ -238,8 +239,7 @@ public interface WebMvcConfigurer {
* {@link org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean}.
* Leave the return value as {@code null} to keep the default.
*/
@Nullable
default Validator getValidator() {
default @Nullable Validator getValidator() {
return null;
}
@@ -248,8 +248,7 @@ public interface WebMvcConfigurer {
* from data binding and validation error codes. Leave the return value as
* {@code null} to keep the default.
*/
@Nullable
default MessageCodesResolver getMessageCodesResolver() {
default @Nullable MessageCodesResolver getMessageCodesResolver() {
return null;
}

View File

@@ -19,9 +19,10 @@ package org.springframework.web.servlet.config.annotation;
import java.util.ArrayList;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.MessageCodesResolver;
import org.springframework.validation.Validator;
@@ -168,8 +169,7 @@ class WebMvcConfigurerComposite implements WebMvcConfigurer {
}
@Override
@Nullable
public Validator getValidator() {
public @Nullable Validator getValidator() {
Validator selected = null;
for (WebMvcConfigurer configurer : this.delegates) {
Validator validator = configurer.getValidator();
@@ -185,8 +185,7 @@ class WebMvcConfigurerComposite implements WebMvcConfigurer {
}
@Override
@Nullable
public MessageCodesResolver getMessageCodesResolver() {
public @Nullable MessageCodesResolver getMessageCodesResolver() {
MessageCodesResolver selected = null;
for (WebMvcConfigurer configurer : this.delegates) {
MessageCodesResolver messageCodesResolver = configurer.getMessageCodesResolver();

View File

@@ -1,9 +1,7 @@
/**
* Annotation-based setup for Spring MVC.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.servlet.config.annotation;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -1,9 +1,7 @@
/**
* Defines the XML configuration namespace for Spring MVC.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.servlet.config;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -24,11 +24,11 @@ import jakarta.servlet.ServletException;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatusCode;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@@ -76,8 +76,7 @@ abstract class AbstractServerResponse extends ErrorHandlingServerResponse {
}
@Override
@Nullable
public ModelAndView writeTo(HttpServletRequest request, HttpServletResponse response,
public @Nullable ModelAndView writeTo(HttpServletRequest request, HttpServletResponse response,
Context context) throws ServletException, IOException {
try {
@@ -128,8 +127,7 @@ abstract class AbstractServerResponse extends ErrorHandlingServerResponse {
.forEach(servletResponse::addCookie);
}
@Nullable
protected abstract ModelAndView writeToInternal(
protected abstract @Nullable ModelAndView writeToInternal(
HttpServletRequest request, HttpServletResponse response, Context context)
throws Exception;

View File

@@ -20,11 +20,11 @@ import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.springframework.core.ReactiveAdapter;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**

View File

@@ -22,10 +22,10 @@ import jakarta.servlet.ServletException;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatusCode;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.MultiValueMap;
import org.springframework.web.servlet.ModelAndView;
@@ -68,8 +68,7 @@ final class CompletedAsyncServerResponse implements AsyncServerResponse {
}
@Override
@Nullable
public ModelAndView writeTo(HttpServletRequest request, HttpServletResponse response, Context context)
public @Nullable ModelAndView writeTo(HttpServletRequest request, HttpServletResponse response, Context context)
throws ServletException, IOException {
return this.serverResponse.writeTo(request, response, context);

View File

@@ -29,10 +29,10 @@ import jakarta.servlet.ServletException;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatusCode;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.util.MultiValueMap;
import org.springframework.web.context.request.async.AsyncWebRequest;
@@ -54,8 +54,7 @@ final class DefaultAsyncServerResponse extends ErrorHandlingServerResponse imple
private final CompletableFuture<ServerResponse> futureResponse;
@Nullable
private final Duration timeout;
private final @Nullable Duration timeout;
DefaultAsyncServerResponse(CompletableFuture<ServerResponse> futureResponse, @Nullable Duration timeout) {
@@ -105,8 +104,7 @@ final class DefaultAsyncServerResponse extends ErrorHandlingServerResponse imple
}
@Override
@Nullable
public ModelAndView writeTo(HttpServletRequest request, HttpServletResponse response, Context context)
public @Nullable ModelAndView writeTo(HttpServletRequest request, HttpServletResponse response, Context context)
throws ServletException, IOException {
writeAsync(request, response, createDeferredResult(request));

View File

@@ -34,6 +34,7 @@ import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponseWrapper;
import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
@@ -57,7 +58,6 @@ import org.springframework.http.converter.GenericHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.SmartHttpMessageConverter;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@@ -260,8 +260,7 @@ final class DefaultEntityResponseBuilder<T> implements EntityResponse.Builder<T>
}
@Override
@Nullable
protected ModelAndView writeToInternal(HttpServletRequest servletRequest,
protected @Nullable ModelAndView writeToInternal(HttpServletRequest servletRequest,
HttpServletResponse servletResponse, Context context)
throws ServletException, IOException {
@@ -322,8 +321,7 @@ final class DefaultEntityResponseBuilder<T> implements EntityResponse.Builder<T>
throw new HttpMediaTypeNotAcceptableException(producibleMediaTypes);
}
@Nullable
private static MediaType getContentType(HttpServletResponse response) {
private static @Nullable MediaType getContentType(HttpServletResponse response) {
try {
return MediaType.parseMediaType(response.getContentType()).removeQualityValue();
}
@@ -367,8 +365,7 @@ final class DefaultEntityResponseBuilder<T> implements EntityResponse.Builder<T>
}
@Override
@Nullable
protected ModelAndView writeToInternal(HttpServletRequest servletRequest, HttpServletResponse servletResponse,
protected @Nullable ModelAndView writeToInternal(HttpServletRequest servletRequest, HttpServletResponse servletResponse,
Context context) throws ServletException, IOException {
DeferredResult<ServerResponse> deferredResult = createDeferredResult(servletRequest, servletResponse, context);
@@ -421,8 +418,7 @@ final class DefaultEntityResponseBuilder<T> implements EntityResponse.Builder<T>
}
@Override
@Nullable
protected ModelAndView writeToInternal(HttpServletRequest servletRequest, HttpServletResponse servletResponse,
protected @Nullable ModelAndView writeToInternal(HttpServletRequest servletRequest, HttpServletResponse servletResponse,
Context context) throws ServletException, IOException {
DeferredResult<?> deferredResult = new DeferredResult<>();
@@ -443,8 +439,7 @@ final class DefaultEntityResponseBuilder<T> implements EntityResponse.Builder<T>
private final DeferredResult<?> deferredResult;
@Nullable
private Subscription subscription;
private @Nullable Subscription subscription;
public DeferredResultSubscriber(HttpServletRequest servletRequest,

View File

@@ -26,12 +26,12 @@ import java.util.function.Consumer;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.core.Conventions;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

View File

@@ -49,6 +49,7 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.Part;
import org.jspecify.annotations.Nullable;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.ResolvableType;
@@ -61,7 +62,6 @@ import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.SmartHttpMessageConverter;
import org.springframework.http.server.RequestPath;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
@@ -101,8 +101,7 @@ class DefaultServerRequest implements ServerRequest {
private final Map<String, Object> attributes;
@Nullable
private MultiValueMap<String, Part> parts;
private @Nullable MultiValueMap<String, Part> parts;
public DefaultServerRequest(HttpServletRequest servletRequest, List<HttpMessageConverter<?>> messageConverters) {
@@ -385,8 +384,7 @@ class DefaultServerRequest implements ServerRequest {
}
@Override
@Nullable
public InetSocketAddress host() {
public @Nullable InetSocketAddress host() {
return this.httpHeaders.getHost();
}
@@ -637,8 +635,7 @@ class DefaultServerRequest implements ServerRequest {
}
@Override
@Nullable
public String getHeader(String name) {
public @Nullable String getHeader(String name) {
return this.headers.getFirst(name);
}

View File

@@ -40,6 +40,7 @@ import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.Part;
import org.jspecify.annotations.Nullable;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.ResolvableType;
@@ -50,7 +51,6 @@ import org.springframework.http.MediaType;
import org.springframework.http.converter.GenericHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.SmartHttpMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@@ -86,8 +86,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
private final MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
@Nullable
private InetSocketAddress remoteAddress;
private @Nullable InetSocketAddress remoteAddress;
private byte[] body = new byte[0];
@@ -228,8 +227,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
private final MultiValueMap<String, String> params;
@Nullable
private final InetSocketAddress remoteAddress;
private final @Nullable InetSocketAddress remoteAddress;
public BuiltServerRequest(HttpServletRequest servletRequest, HttpMethod method, URI uri,
HttpHeaders headers, MultiValueMap<String, Cookie> cookies,

View File

@@ -28,6 +28,7 @@ import java.util.function.Consumer;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.CacheControl;
@@ -35,7 +36,6 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.MediaType;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@@ -69,7 +69,8 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
}
@Override
public ServerResponse.BodyBuilder header(String headerName, String... headerValues) {
@SuppressWarnings("NullAway") // TODO NullAway bug potentially due to the recursive generic type
public ServerResponse.BodyBuilder header(String headerName, @Nullable String... headerValues) {
Assert.notNull(headerName, "HeaderName must not be null");
for (String headerValue : headerValues) {
this.headers.add(headerName, headerValue);
@@ -227,8 +228,7 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
}
@Override
@Nullable
protected ModelAndView writeToInternal(HttpServletRequest request, HttpServletResponse response,
protected @Nullable ModelAndView writeToInternal(HttpServletRequest request, HttpServletResponse response,
Context context) throws Exception {
return this.writeFunction.write(request, response);

View File

@@ -27,8 +27,8 @@ 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.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.servlet.ModelAndView;
@@ -52,8 +52,7 @@ abstract class ErrorHandlingServerResponse implements ServerResponse {
this.errorHandlers.add(new ErrorHandler<>(predicate, errorHandler));
}
@Nullable
protected final ModelAndView handleError(Throwable t, HttpServletRequest servletRequest,
protected final @Nullable ModelAndView handleError(Throwable t, HttpServletRequest servletRequest,
HttpServletResponse servletResponse, Context context) throws ServletException, IOException {
ServerResponse serverResponse = errorResponse(t, servletRequest);
@@ -71,8 +70,7 @@ abstract class ErrorHandlingServerResponse implements ServerResponse {
}
}
@Nullable
protected final ServerResponse errorResponse(Throwable t, HttpServletRequest servletRequest) {
protected final @Nullable ServerResponse errorResponse(Throwable t, HttpServletRequest servletRequest) {
for (ErrorHandler<?> errorHandler : this.errorHandlers) {
if (errorHandler.test(t)) {
ServerRequest serverRequest = (ServerRequest)

View File

@@ -21,10 +21,10 @@ import java.util.Map;
import java.util.function.Consumer;
import jakarta.servlet.http.Cookie;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatusCode;
import org.springframework.lang.Nullable;
import org.springframework.util.MultiValueMap;
/**

View File

@@ -40,6 +40,7 @@ import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.Part;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpHeaders;
@@ -48,7 +49,6 @@ import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.PathContainer;
import org.springframework.http.server.RequestPath;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.MimeTypeUtils;
@@ -479,8 +479,8 @@ public abstract class RequestPredicates {
private final boolean value;
@Nullable
private final Consumer<Map<String, Object>> modifyAttributes;
private final @Nullable Consumer<Map<String, Object>> modifyAttributes;
private Result(boolean value, @Nullable Consumer<Map<String, Object>> modifyAttributes) {
@@ -818,8 +818,7 @@ public abstract class RequestPredicates {
private final Predicate<String> extensionPredicate;
@Nullable
private final String extension;
private final @Nullable String extension;
public PathExtensionPredicate(Predicate<String> extensionPredicate) {
Assert.notNull(extensionPredicate, "Predicate must not be null");
@@ -868,8 +867,7 @@ public abstract class RequestPredicates {
private final Predicate<String> valuePredicate;
@Nullable
private final String value;
private final @Nullable String value;
public ParamPredicate(String name, Predicate<String> valuePredicate) {
Assert.notNull(name, "Name must not be null");

View File

@@ -25,11 +25,12 @@ import java.net.URL;
import java.util.Set;
import java.util.function.BiConsumer;
import org.jspecify.annotations.Nullable;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.lang.Nullable;
/**
* Resource-based implementation of {@link HandlerFunction}.
@@ -130,8 +131,7 @@ class ResourceHandlerFunction implements HandlerFunction<ServerResponse> {
}
@Override
@Nullable
public String getFilename() {
public @Nullable String getFilename() {
return this.delegate.getFilename();
}

View File

@@ -34,6 +34,7 @@ import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.Part;
import org.jspecify.annotations.Nullable;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.buffer.DataBuffer;
@@ -44,7 +45,6 @@ import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.PathContainer;
import org.springframework.http.server.RequestPath;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.MultiValueMap;
@@ -445,8 +445,7 @@ public interface ServerRequest {
* {@linkplain InetSocketAddress#getPort() port} in the returned address will
* be {@code 0}.
*/
@Nullable
InetSocketAddress host();
@Nullable InetSocketAddress host();
/**
* Get the value of the {@code Range} header.
@@ -467,8 +466,7 @@ public interface ServerRequest {
* @param headerName the header name
* @since 5.2.5
*/
@Nullable
default String firstHeader(String headerName) {
default @Nullable String firstHeader(String headerName) {
List<String> list = header(headerName);
return list.isEmpty() ? null : list.get(0);
}

View File

@@ -33,6 +33,7 @@ import jakarta.servlet.ServletException;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.springframework.core.ParameterizedTypeReference;
@@ -44,7 +45,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.util.MultiValueMap;
import org.springframework.web.ErrorResponse;
import org.springframework.web.servlet.ModelAndView;
@@ -82,8 +82,7 @@ public interface ServerResponse {
* @param context the context to use when writing
* @return a {@code ModelAndView} to render, or {@code null} if handled directly
*/
@Nullable
ModelAndView writeTo(HttpServletRequest request, HttpServletResponse response, Context context)
@Nullable ModelAndView writeTo(HttpServletRequest request, HttpServletResponse response, Context context)
throws ServletException, IOException;
@@ -335,7 +334,7 @@ public interface ServerResponse {
* @return this builder
* @see HttpHeaders#add(String, String)
*/
B header(String headerName, String... headerValues);
B header(String headerName, @Nullable String... headerValues);
/**
* Manipulate this response's headers with the given consumer. The
@@ -466,8 +465,7 @@ public interface ServerResponse {
* @return a {@code ModelAndView} to render, or {@code null} if handled directly
* @throws Exception in case of Servlet errors
*/
@Nullable
ModelAndView write(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception;
@Nullable ModelAndView write(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception;
}

View File

@@ -28,6 +28,7 @@ import jakarta.servlet.ServletException;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.http.CacheControl;
import org.springframework.http.HttpHeaders;
@@ -37,7 +38,6 @@ import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.DelegatingServerHttpResponse;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.MultiValueMap;
@@ -56,8 +56,7 @@ final class SseServerResponse extends AbstractServerResponse {
private final Consumer<SseBuilder> sseConsumer;
@Nullable
private final Duration timeout;
private final @Nullable Duration timeout;
private SseServerResponse(Consumer<SseBuilder> sseConsumer, @Nullable Duration timeout) {
@@ -78,9 +77,8 @@ final class SseServerResponse extends AbstractServerResponse {
}
@Nullable
@Override
protected ModelAndView writeToInternal(HttpServletRequest request, HttpServletResponse response,
protected @Nullable ModelAndView writeToInternal(HttpServletRequest request, HttpServletResponse response,
Context context) throws ServletException, IOException {
DeferredResult<?> result;

View File

@@ -25,6 +25,7 @@ import java.util.function.Consumer;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatusCode;
@@ -33,7 +34,6 @@ import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.DelegatingServerHttpResponse;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.MultiValueMap;
import org.springframework.web.context.request.async.DeferredResult;
@@ -48,8 +48,7 @@ final class StreamingServerResponse extends AbstractServerResponse {
private final Consumer<StreamBuilder> streamConsumer;
@Nullable
private final Duration timeout;
private final @Nullable Duration timeout;
private StreamingServerResponse(HttpStatusCode statusCode, HttpHeaders headers, MultiValueMap<String, Cookie> cookies,
Consumer<StreamBuilder> streamConsumer, @Nullable Duration timeout) {
@@ -67,9 +66,8 @@ final class StreamingServerResponse extends AbstractServerResponse {
return new StreamingServerResponse(statusCode, headers, cookies, streamConsumer, timeout);
}
@Nullable
@Override
protected ModelAndView writeToInternal(HttpServletRequest request, HttpServletResponse response, Context context) throws Exception {
protected @Nullable ModelAndView writeToInternal(HttpServletRequest request, HttpServletResponse response, Context context) throws Exception {
DeferredResult<?> result;
if (this.timeout != null) {
result = new DeferredResult<>(this.timeout.toMillis());

View File

@@ -1,9 +1,7 @@
/**
* Provides the types that make up Spring's functional web framework for Servlet environments.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.servlet.function;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -23,11 +23,11 @@ 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.core.Ordered;
import org.springframework.core.log.LogFormatUtils;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.context.request.async.AsyncWebRequest;
import org.springframework.web.context.request.async.WebAsyncManager;
@@ -51,8 +51,7 @@ public class HandlerFunctionAdapter implements HandlerAdapter, Ordered {
private int order = Ordered.LOWEST_PRECEDENCE;
@Nullable
private Long asyncRequestTimeout;
private @Nullable Long asyncRequestTimeout;
/**
* Specify the order value for this HandlerAdapter bean.
@@ -88,9 +87,8 @@ public class HandlerFunctionAdapter implements HandlerAdapter, Ordered {
return handler instanceof HandlerFunction;
}
@Nullable
@Override
public ModelAndView handle(HttpServletRequest servletRequest,
public @Nullable ModelAndView handle(HttpServletRequest servletRequest,
HttpServletResponse servletResponse,
Object handler) throws Exception {
@@ -149,8 +147,7 @@ public class HandlerFunctionAdapter implements HandlerAdapter, Ordered {
return serverRequest;
}
@Nullable
private ServerResponse handleAsync(WebAsyncManager asyncManager) throws Exception {
private @Nullable ServerResponse handleAsync(WebAsyncManager asyncManager) throws Exception {
Object result = asyncManager.getConcurrentResult();
asyncManager.clearConcurrentResult();
LogFormatUtils.traceDebug(logger, traceOn -> {

View File

@@ -22,6 +22,7 @@ import java.util.List;
import java.util.stream.Collectors;
import jakarta.servlet.http.HttpServletRequest;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
@@ -29,7 +30,6 @@ import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
import org.springframework.web.filter.ServerHttpObservationFilter;
import org.springframework.web.servlet.function.HandlerFunction;
@@ -57,8 +57,7 @@ import org.springframework.web.util.pattern.PathPatternParser;
*/
public class RouterFunctionMapping extends AbstractHandlerMapping implements InitializingBean, MatchableHandlerMapping {
@Nullable
private RouterFunction<?> routerFunction;
private @Nullable RouterFunction<?> routerFunction;
private List<HttpMessageConverter<?>> messageConverters = Collections.emptyList();
@@ -98,8 +97,7 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
* prior to {@link #afterPropertiesSet()}.
* @return the router function or {@code null}
*/
@Nullable
public RouterFunction<?> getRouterFunction() {
public @Nullable RouterFunction<?> getRouterFunction() {
return this.routerFunction;
}
@@ -197,8 +195,7 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
@Override
@Nullable
protected Object getHandlerInternal(HttpServletRequest servletRequest) throws Exception {
protected @Nullable Object getHandlerInternal(HttpServletRequest servletRequest) throws Exception {
if (this.routerFunction != null) {
ServerRequest request = ServerRequest.create(servletRequest, this.messageConverters);
HandlerFunction<?> handlerFunction = this.routerFunction.route(request).orElse(null);
@@ -225,9 +222,8 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
servletRequest.setAttribute(RouterFunctions.REQUEST_ATTRIBUTE, request);
}
@Nullable
@Override
public RequestMatchResult match(HttpServletRequest request, String pattern) {
public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) {
throw new UnsupportedOperationException("This HandlerMapping uses PathPatterns");
}
}

View File

@@ -3,9 +3,7 @@
* Contains a {@code HandlerAdapter} that supports {@code HandlerFunction}s,
* and a {@code HandlerMapping} that supports {@code RouterFunction}s.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.servlet.function.support;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -23,10 +23,10 @@ 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.core.Ordered;
import org.springframework.core.log.LogFormatUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerExceptionResolver;
@@ -61,17 +61,13 @@ public abstract class AbstractHandlerExceptionResolver implements HandlerExcepti
private int order = Ordered.LOWEST_PRECEDENCE;
@Nullable
private Predicate<Object> mappedHandlerPredicate;
private @Nullable Predicate<Object> mappedHandlerPredicate;
@Nullable
private Set<?> mappedHandlers;
private @Nullable Set<?> mappedHandlers;
@Nullable
private Class<?>[] mappedHandlerClasses;
private Class<?> @Nullable [] mappedHandlerClasses;
@Nullable
private Log warnLogger;
private @Nullable Log warnLogger;
private boolean preventResponseCaching = false;
@@ -134,8 +130,7 @@ public abstract class AbstractHandlerExceptionResolver implements HandlerExcepti
* Return the {@link #setMappedHandlerClasses(Class[]) configured} mapped
* handler classes.
*/
@Nullable
protected Class<?>[] getMappedHandlerClasses() {
protected Class<?> @Nullable [] getMappedHandlerClasses() {
return this.mappedHandlerClasses;
}
@@ -173,8 +168,7 @@ public abstract class AbstractHandlerExceptionResolver implements HandlerExcepti
* to the {@link #doResolveException} template method.
*/
@Override
@Nullable
public ModelAndView resolveException(
public @Nullable ModelAndView resolveException(
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) {
if (shouldApplyTo(request, handler)) {
@@ -305,8 +299,7 @@ public abstract class AbstractHandlerExceptionResolver implements HandlerExcepti
* @return a corresponding {@code ModelAndView} to forward to,
* or {@code null} for default processing in the resolution chain
*/
@Nullable
protected abstract ModelAndView doResolveException(
protected abstract @Nullable ModelAndView doResolveException(
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex);
}

View File

@@ -26,6 +26,7 @@ import jakarta.servlet.DispatcherType;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactoryUtils;
@@ -33,7 +34,6 @@ import org.springframework.beans.factory.BeanNameAware;
import org.springframework.core.Ordered;
import org.springframework.core.log.LogDelegateFactory;
import org.springframework.http.server.RequestPath;
import org.springframework.lang.Nullable;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -88,11 +88,9 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
LogDelegateFactory.getHiddenLog(HandlerMapping.class.getName() + ".Mappings");
@Nullable
private Object defaultHandler;
private @Nullable Object defaultHandler;
@Nullable
private PathPatternParser patternParser = new PathPatternParser();
private @Nullable PathPatternParser patternParser = new PathPatternParser();
private UrlPathHelper urlPathHelper = new UrlPathHelper();
@@ -102,15 +100,13 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
private final List<HandlerInterceptor> adaptedInterceptors = new ArrayList<>();
@Nullable
private CorsConfigurationSource corsConfigurationSource;
private @Nullable CorsConfigurationSource corsConfigurationSource;
private CorsProcessor corsProcessor = new DefaultCorsProcessor();
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
@Nullable
private String beanName;
private @Nullable String beanName;
/**
@@ -126,8 +122,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* Return the default handler for this handler mapping,
* or {@code null} if none.
*/
@Nullable
public Object getDefaultHandler() {
public @Nullable Object getDefaultHandler() {
return this.defaultHandler;
}
@@ -173,8 +168,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* String pattern matching with {@link AntPathMatcher} is enabled instead.
* @since 5.3
*/
@Nullable
public PathPatternParser getPatternParser() {
public @Nullable PathPatternParser getPatternParser() {
return this.patternParser;
}
@@ -288,8 +282,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* or more specifically before
* {@link org.springframework.context.ApplicationContextAware#setApplicationContext}.
*/
@Nullable
public final HandlerInterceptor[] getAdaptedInterceptors() {
public final HandlerInterceptor @Nullable [] getAdaptedInterceptors() {
return (!this.adaptedInterceptors.isEmpty() ?
this.adaptedInterceptors.toArray(new HandlerInterceptor[0]) : null);
}
@@ -298,8 +291,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* Return all configured {@link MappedInterceptor}s as an array.
* @return the array of {@link MappedInterceptor}s, or {@code null} if none
*/
@Nullable
protected final MappedInterceptor[] getMappedInterceptors() {
protected final MappedInterceptor @Nullable [] getMappedInterceptors() {
List<MappedInterceptor> mappedInterceptors = new ArrayList<>(this.adaptedInterceptors.size());
for (HandlerInterceptor interceptor : this.adaptedInterceptors) {
if (interceptor instanceof MappedInterceptor mappedInterceptor) {
@@ -360,8 +352,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* configured} {@code CorsConfigurationSource}, if any.
* @since 5.3
*/
@Nullable
public CorsConfigurationSource getCorsConfigurationSource() {
public @Nullable CorsConfigurationSource getCorsConfigurationSource() {
return this.corsConfigurationSource;
}
@@ -504,8 +495,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* @see #getHandlerInternal
*/
@Override
@Nullable
public final HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
public final @Nullable HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
Object handler = getHandlerInternal(request);
if (handler == null) {
handler = getDefaultHandler();
@@ -566,8 +556,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* @return the corresponding handler instance, or {@code null} if none found
* @throws Exception if there is an internal error
*/
@Nullable
protected abstract Object getHandlerInternal(HttpServletRequest request) throws Exception;
protected abstract @Nullable Object getHandlerInternal(HttpServletRequest request) throws Exception;
/**
* Initialize the path to use for request mapping.
@@ -656,8 +645,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* @return the CORS configuration for the handler, or {@code null} if none
* @since 4.2
*/
@Nullable
protected CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request) {
protected @Nullable CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request) {
Object resolvedHandler = handler;
if (handler instanceof HandlerExecutionChain handlerExecutionChain) {
resolvedHandler = handlerExecutionChain.getHandler();
@@ -694,16 +682,14 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
private class CorsInterceptor implements HandlerInterceptor, CorsConfigurationSource {
@Nullable
private final CorsConfiguration config;
private final @Nullable CorsConfiguration config;
public CorsInterceptor(@Nullable CorsConfiguration config) {
this.config = config;
}
@Override
@Nullable
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
public @Nullable CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
return this.config;
}

View File

@@ -18,8 +18,8 @@ package org.springframework.web.servlet.handler;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
@@ -65,8 +65,7 @@ public abstract class AbstractHandlerMethodExceptionResolver extends AbstractHan
}
@Override
@Nullable
protected final ModelAndView doResolveException(
protected final @Nullable ModelAndView doResolveException(
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) {
HandlerMethod handlerMethod = (handler instanceof HandlerMethod hm ? hm : null);
@@ -87,8 +86,7 @@ public abstract class AbstractHandlerMethodExceptionResolver extends AbstractHan
* @param ex the exception that got thrown during handler execution
* @return a corresponding ModelAndView to forward to, or {@code null} for default processing
*/
@Nullable
protected abstract ModelAndView doResolveHandlerMethodException(
protected abstract @Nullable ModelAndView doResolveHandlerMethodException(
HttpServletRequest request, HttpServletResponse response, @Nullable HandlerMethod handlerMethod, Exception ex);
}

View File

@@ -34,12 +34,12 @@ import java.util.stream.Collectors;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import org.jspecify.annotations.Nullable;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.MethodIntrospector;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.LinkedMultiValueMap;
@@ -95,8 +95,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
private boolean detectHandlerMethodsInAncestorContexts = false;
@Nullable
private HandlerMethodMappingNamingStrategy<T> namingStrategy;
private @Nullable HandlerMethodMappingNamingStrategy<T> namingStrategy;
private final MappingRegistry mappingRegistry = new MappingRegistry();
@@ -136,8 +135,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
/**
* Return the configured naming strategy or {@code null}.
*/
@Nullable
public HandlerMethodMappingNamingStrategy<T> getNamingStrategy() {
public @Nullable HandlerMethodMappingNamingStrategy<T> getNamingStrategy() {
return this.namingStrategy;
}
@@ -162,8 +160,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
* list will never be modified and is safe to iterate.
* @see #setHandlerMethodMappingNamingStrategy
*/
@Nullable
public List<HandlerMethod> getHandlerMethodsForMappingName(String mappingName) {
public @Nullable List<HandlerMethod> getHandlerMethodsForMappingName(String mappingName) {
return this.mappingRegistry.getHandlerMethodsByMappingName(mappingName);
}
@@ -350,8 +347,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
/**
* Extract and return the CORS configuration for the mapping.
*/
@Nullable
protected CorsConfiguration initCorsConfiguration(Object handler, Method method, T mapping) {
protected @Nullable CorsConfiguration initCorsConfiguration(Object handler, Method method, T mapping) {
return null;
}
@@ -374,8 +370,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
* Look up a handler method for the given request.
*/
@Override
@Nullable
protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception {
protected @Nullable HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception {
String lookupPath = initLookupPath(request);
this.mappingRegistry.acquireReadLock();
try {
@@ -396,8 +391,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
* @see #handleMatch(Object, String, HttpServletRequest)
* @see #handleNoMatch(Set, String, HttpServletRequest)
*/
@Nullable
protected HandlerMethod lookupHandlerMethod(String lookupPath, HttpServletRequest request) throws Exception {
protected @Nullable HandlerMethod lookupHandlerMethod(String lookupPath, HttpServletRequest request) throws Exception {
List<Match> matches = new ArrayList<>();
List<T> directPathMatches = this.mappingRegistry.getMappingsByDirectPath(lookupPath);
if (directPathMatches != null) {
@@ -469,8 +463,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
* @param request the current request
* @throws ServletException in case of errors
*/
@Nullable
protected HandlerMethod handleNoMatch(Set<T> mappings, String lookupPath, HttpServletRequest request)
protected @Nullable HandlerMethod handleNoMatch(Set<T> mappings, String lookupPath, HttpServletRequest request)
throws Exception {
return null;
@@ -484,8 +477,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
}
@Override
@Nullable
protected CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request) {
protected @Nullable CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request) {
CorsConfiguration corsConfig = super.getCorsConfiguration(handler, request);
if (handler instanceof HandlerMethod handlerMethod) {
if (handlerMethod.equals(PREFLIGHT_AMBIGUOUS_MATCH)) {
@@ -517,8 +509,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
* declaring class
* @return the mapping, or {@code null} if the method is not mapped
*/
@Nullable
protected abstract T getMappingForMethod(Method method, Class<?> handlerType);
protected abstract @Nullable T getMappingForMethod(Method method, Class<?> handlerType);
/**
* Extract and return the URL paths contained in the supplied mapping.
@@ -552,8 +543,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
* @param request the current HTTP servlet request
* @return the match, or {@code null} if the mapping doesn't match
*/
@Nullable
protected abstract T getMatchingMapping(T mapping, HttpServletRequest request);
protected abstract @Nullable T getMatchingMapping(T mapping, HttpServletRequest request);
/**
* Return a comparator for sorting matching mappings.
@@ -594,24 +584,21 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
* Return matches for the given URL path. Not thread-safe.
* @see #acquireReadLock()
*/
@Nullable
public List<T> getMappingsByDirectPath(String urlPath) {
public @Nullable List<T> getMappingsByDirectPath(String urlPath) {
return this.pathLookup.get(urlPath);
}
/**
* Return handler methods by mapping name. Thread-safe for concurrent use.
*/
@Nullable
public List<HandlerMethod> getHandlerMethodsByMappingName(String mappingName) {
public @Nullable List<HandlerMethod> getHandlerMethodsByMappingName(String mappingName) {
return this.nameLookup.get(mappingName);
}
/**
* Return CORS configuration. Thread-safe for concurrent use.
*/
@Nullable
public CorsConfiguration getCorsConfiguration(HandlerMethod handlerMethod) {
public @Nullable CorsConfiguration getCorsConfiguration(HandlerMethod handlerMethod) {
HandlerMethod original = handlerMethod.getResolvedFromHandlerMethod();
return this.corsLookup.get(original != null ? original : handlerMethod);
}
@@ -754,8 +741,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
private final Set<String> directPaths;
@Nullable
private final String mappingName;
private final @Nullable String mappingName;
private final boolean corsConfig;
@@ -783,8 +769,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
return this.directPaths;
}
@Nullable
public String getMappingName() {
public @Nullable String getMappingName() {
return this.mappingName;
}

View File

@@ -25,11 +25,11 @@ import java.util.Map;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.http.server.RequestPath;
import org.springframework.lang.Nullable;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -63,8 +63,7 @@ import org.springframework.web.util.pattern.PathPatternParser;
*/
public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping implements MatchableHandlerMapping {
@Nullable
private Object rootHandler;
private @Nullable Object rootHandler;
private boolean lazyInitHandlers = false;
@@ -94,8 +93,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
* Return the root handler for this handler mapping (registered for "/"),
* or {@code null} if none.
*/
@Nullable
public Object getRootHandler() {
public @Nullable Object getRootHandler() {
return this.rootHandler;
}
@@ -232,8 +230,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
* @return the handler instance, or {@code null} if none found
*/
@Override
@Nullable
protected Object getHandlerInternal(HttpServletRequest request) throws Exception {
protected @Nullable Object getHandlerInternal(HttpServletRequest request) throws Exception {
String lookupPath = initLookupPath(request);
Object handler;
if (usesPathPatterns()) {
@@ -274,9 +271,8 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
* @return a matching handler, or {@code null} if not found
* @since 5.3
*/
@Nullable
@SuppressWarnings("NullAway")
protected Object lookupHandler(
protected @Nullable Object lookupHandler(
RequestPath path, String lookupPath, HttpServletRequest request) throws Exception {
Object handler = getDirectMatch(lookupPath, request);
@@ -323,8 +319,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
* @see #exposePathWithinMapping
* @see AntPathMatcher
*/
@Nullable
protected Object lookupHandler(String lookupPath, HttpServletRequest request) throws Exception {
protected @Nullable Object lookupHandler(String lookupPath, HttpServletRequest request) throws Exception {
Object handler = getDirectMatch(lookupPath, request);
if (handler != null) {
return handler;
@@ -385,8 +380,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
return null;
}
@Nullable
private Object getDirectMatch(String urlPath, HttpServletRequest request) throws Exception {
private @Nullable Object getDirectMatch(String urlPath, HttpServletRequest request) throws Exception {
Object handler = this.handlerMap.get(urlPath);
if (handler != null) {
// Bean name or resolved handler?
@@ -459,8 +453,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
}
@Override
@Nullable
public RequestMatchResult match(HttpServletRequest request, String pattern) {
public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) {
Assert.state(getPatternParser() == null, "This HandlerMapping uses PathPatterns.");
String lookupPath = UrlPathHelper.getResolvedLookupPath(request);
if (getPathMatcher().match(pattern, lookupPath)) {

View File

@@ -21,9 +21,9 @@ import java.util.List;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
@@ -36,8 +36,7 @@ import org.springframework.web.servlet.ModelAndView;
*/
public class HandlerExceptionResolverComposite implements HandlerExceptionResolver, Ordered {
@Nullable
private List<HandlerExceptionResolver> resolvers;
private @Nullable List<HandlerExceptionResolver> resolvers;
private int order = Ordered.LOWEST_PRECEDENCE;
@@ -71,8 +70,7 @@ public class HandlerExceptionResolverComposite implements HandlerExceptionResolv
* <p>The first one to return a {@link ModelAndView} wins. Otherwise {@code null} is returned.
*/
@Override
@Nullable
public ModelAndView resolveException(
public @Nullable ModelAndView resolveException(
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) {
if (this.resolvers != null) {

View File

@@ -36,6 +36,7 @@ import jakarta.servlet.http.HttpServletRequestWrapper;
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.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.InitializingBean;
@@ -47,7 +48,6 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.http.server.RequestPath;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
@@ -100,11 +100,9 @@ public class HandlerMappingIntrospector
HandlerMappingIntrospector.class.getName() + ".CachedResult";
@Nullable
private ApplicationContext applicationContext;
private @Nullable ApplicationContext applicationContext;
@Nullable
private List<HandlerMapping> handlerMappings;
private @Nullable List<HandlerMapping> handlerMappings;
private Map<HandlerMapping, PathPatternMatchableHandlerMapping> pathPatternMappings = Collections.emptyMap();
@@ -257,8 +255,7 @@ public class HandlerMappingIntrospector
* @return the previous {@link CachedResult}, if there is one from a parent dispatch
* @since 6.0.14
*/
@Nullable
public CachedResult setCache(HttpServletRequest request) {
public @Nullable CachedResult setCache(HttpServletRequest request) {
CachedResult previous = (CachedResult) request.getAttribute(CACHED_RESULT_ATTRIBUTE);
if (previous == null || !previous.matches(request)) {
HttpServletRequest wrapped = new AttributesPreservingRequest(request);
@@ -310,8 +307,7 @@ public class HandlerMappingIntrospector
* instance of {@link MatchableHandlerMapping}
* @throws Exception if any of the HandlerMapping's raise an exception
*/
@Nullable
public MatchableHandlerMapping getMatchableHandlerMapping(HttpServletRequest request) throws Exception {
public @Nullable MatchableHandlerMapping getMatchableHandlerMapping(HttpServletRequest request) throws Exception {
CachedResult result = CachedResult.getResultFor(request);
if (result != null) {
return result.getHandlerMapping();
@@ -338,8 +334,7 @@ public class HandlerMappingIntrospector
}
@Override
@Nullable
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
public @Nullable CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
CachedResult result = CachedResult.getResultFor(request);
if (result != null) {
return result.getCorsConfig();
@@ -357,8 +352,7 @@ public class HandlerMappingIntrospector
}
}
@Nullable
private static CorsConfiguration getCorsConfiguration(HandlerExecutionChain chain, HttpServletRequest request) {
private static @Nullable CorsConfiguration getCorsConfiguration(HandlerExecutionChain chain, HttpServletRequest request) {
for (HandlerInterceptor interceptor : chain.getInterceptorList()) {
if (interceptor instanceof CorsConfigurationSource source) {
return source.getCorsConfiguration(request);
@@ -370,8 +364,7 @@ public class HandlerMappingIntrospector
return null;
}
@Nullable
private <T> T doWithHandlerMapping(
private <T> @Nullable T doWithHandlerMapping(
HttpServletRequest request, boolean ignoreException,
BiFunction<HandlerMapping, HandlerExecutionChain, T> extractor) throws Exception {
@@ -421,17 +414,13 @@ public class HandlerMappingIntrospector
private final String requestURI;
@Nullable
private final MatchableHandlerMapping handlerMapping;
private final @Nullable MatchableHandlerMapping handlerMapping;
@Nullable
private final CorsConfiguration corsConfig;
private final @Nullable CorsConfiguration corsConfig;
@Nullable
private final Exception failure;
private final @Nullable Exception failure;
@Nullable
private final IllegalStateException corsConfigFailure;
private final @Nullable IllegalStateException corsConfigFailure;
private CachedResult(HttpServletRequest request,
@Nullable MatchableHandlerMapping mapping, @Nullable CorsConfiguration config,
@@ -450,16 +439,14 @@ public class HandlerMappingIntrospector
this.requestURI.equals(request.getRequestURI()));
}
@Nullable
public MatchableHandlerMapping getHandlerMapping() throws Exception {
public @Nullable MatchableHandlerMapping getHandlerMapping() throws Exception {
if (this.failure != null) {
throw this.failure;
}
return this.handlerMapping;
}
@Nullable
public CorsConfiguration getCorsConfig() {
public @Nullable CorsConfiguration getCorsConfig() {
if (this.corsConfigFailure != null) {
throw this.corsConfigFailure;
}
@@ -475,8 +462,7 @@ public class HandlerMappingIntrospector
/**
* Return a {@link CachedResult} that matches the given request.
*/
@Nullable
public static CachedResult getResultFor(HttpServletRequest request) {
public static @Nullable CachedResult getResultFor(HttpServletRequest request) {
CachedResult result = (CachedResult) request.getAttribute(CACHED_RESULT_ATTRIBUTE);
return (result != null && result.matches(request) ? result : null);
}
@@ -548,8 +534,7 @@ public class HandlerMappingIntrospector
}
@Override
@Nullable
public Object getAttribute(String name) {
public @Nullable Object getAttribute(String name) {
return this.attributes.get(name);
}
@@ -581,14 +566,12 @@ public class HandlerMappingIntrospector
}
@Override
@Nullable
public PathPatternParser getPatternParser() {
public @Nullable PathPatternParser getPatternParser() {
return this.delegate.getPatternParser();
}
@Nullable
@Override
public RequestMatchResult match(HttpServletRequest request, String pattern) {
public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) {
pattern = initFullPathPattern(pattern);
Object previousPath = request.getAttribute(this.pathAttributeName);
request.setAttribute(this.pathAttributeName, this.lookupPath);
@@ -605,9 +588,8 @@ public class HandlerMappingIntrospector
return parser.initFullPathPattern(pattern);
}
@Nullable
@Override
public HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
public @Nullable HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
return this.delegate.getHandler(request);
}
}

View File

@@ -20,9 +20,9 @@ import java.util.Arrays;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.http.server.PathContainer;
import org.springframework.lang.Nullable;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.ObjectUtils;
import org.springframework.util.PathMatcher;
@@ -63,11 +63,9 @@ public final class MappedInterceptor implements HandlerInterceptor {
private static final PathMatcher defaultPathMatcher = new AntPathMatcher();
@Nullable
private final PatternAdapter[] includePatterns;
private final PatternAdapter @Nullable [] includePatterns;
@Nullable
private final PatternAdapter[] excludePatterns;
private final PatternAdapter @Nullable [] excludePatterns;
private PathMatcher pathMatcher = defaultPathMatcher;
@@ -85,7 +83,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
* when not provided, {@link PathPatternParser#defaultInstance} is used.
* @since 5.3
*/
public MappedInterceptor(@Nullable String[] includePatterns, @Nullable String[] excludePatterns,
public MappedInterceptor(String @Nullable [] includePatterns, String @Nullable [] excludePatterns,
HandlerInterceptor interceptor, @Nullable PathPatternParser parser) {
this.includePatterns = PatternAdapter.initPatterns(includePatterns, parser);
@@ -99,7 +97,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
* {@link #MappedInterceptor(String[], String[], HandlerInterceptor, PathPatternParser)}
* with include patterns only.
*/
public MappedInterceptor(@Nullable String[] includePatterns, HandlerInterceptor interceptor) {
public MappedInterceptor(String @Nullable [] includePatterns, HandlerInterceptor interceptor) {
this(includePatterns, null, interceptor);
}
@@ -108,7 +106,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
* {@link #MappedInterceptor(String[], String[], HandlerInterceptor, PathPatternParser)}
* without a provided parser.
*/
public MappedInterceptor(@Nullable String[] includePatterns, @Nullable String[] excludePatterns,
public MappedInterceptor(String @Nullable [] includePatterns, String @Nullable [] excludePatterns,
HandlerInterceptor interceptor) {
this(includePatterns, excludePatterns, interceptor, null);
@@ -119,7 +117,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
* {@link #MappedInterceptor(String[], String[], HandlerInterceptor, PathPatternParser)}
* with a {@link WebRequestInterceptor} as the target.
*/
public MappedInterceptor(@Nullable String[] includePatterns, WebRequestInterceptor interceptor) {
public MappedInterceptor(String @Nullable [] includePatterns, WebRequestInterceptor interceptor) {
this(includePatterns, null, interceptor);
}
@@ -128,7 +126,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
* {@link #MappedInterceptor(String[], String[], HandlerInterceptor, PathPatternParser)}
* with a {@link WebRequestInterceptor} as the target.
*/
public MappedInterceptor(@Nullable String[] includePatterns, @Nullable String[] excludePatterns,
public MappedInterceptor(String @Nullable [] includePatterns, String @Nullable [] excludePatterns,
WebRequestInterceptor interceptor) {
this(includePatterns, excludePatterns, new WebRequestHandlerInterceptorAdapter(interceptor));
@@ -140,8 +138,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
* @since 6.1
* @see #getExcludePathPatterns()
*/
@Nullable
public String[] getIncludePathPatterns() {
public String @Nullable [] getIncludePathPatterns() {
return (!ObjectUtils.isEmpty(this.includePatterns) ?
Arrays.stream(this.includePatterns).map(PatternAdapter::getPatternString).toArray(String[]::new) :
null);
@@ -152,8 +149,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
* @since 6.1
* @see #getIncludePathPatterns()
*/
@Nullable
public String[] getExcludePathPatterns() {
public String @Nullable [] getExcludePathPatterns() {
return (!ObjectUtils.isEmpty(this.excludePatterns) ?
Arrays.stream(this.excludePatterns).map(PatternAdapter::getPatternString).toArray(String[]::new) :
null);
@@ -284,8 +280,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
private final String patternString;
@Nullable
private final PathPattern pathPattern;
private final @Nullable PathPattern pathPattern;
public PatternAdapter(String pattern, @Nullable PathPatternParser parser) {
@@ -293,8 +288,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
this.pathPattern = initPathPattern(pattern, parser);
}
@Nullable
private static PathPattern initPathPattern(String pattern, @Nullable PathPatternParser parser) {
private static @Nullable PathPattern initPathPattern(String pattern, @Nullable PathPatternParser parser) {
try {
return (parser != null ? parser : PathPatternParser.defaultInstance).parse(pattern);
}
@@ -319,9 +313,8 @@ public final class MappedInterceptor implements HandlerInterceptor {
return pathMatcher.match(this.patternString, (String) path);
}
@Nullable
public static PatternAdapter[] initPatterns(
@Nullable String[] patterns, @Nullable PathPatternParser parser) {
public static PatternAdapter @Nullable [] initPatterns(
String @Nullable [] patterns, @Nullable PathPatternParser parser) {
if (ObjectUtils.isEmpty(patterns)) {
return null;

View File

@@ -17,8 +17,8 @@
package org.springframework.web.servlet.handler;
import jakarta.servlet.http.HttpServletRequest;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.util.pattern.PathPatternParser;
@@ -38,8 +38,7 @@ public interface MatchableHandlerMapping extends HandlerMapping {
* case pre-parsed patterns are used.
* @since 5.3
*/
@Nullable
default PathPatternParser getPatternParser() {
default @Nullable PathPatternParser getPatternParser() {
return null;
}
@@ -51,7 +50,6 @@ public interface MatchableHandlerMapping extends HandlerMapping {
* @param pattern the pattern to match
* @return the result from request matching, or {@code null} if none
*/
@Nullable
RequestMatchResult match(HttpServletRequest request, String pattern);
@Nullable RequestMatchResult match(HttpServletRequest request, String pattern);
}

View File

@@ -20,9 +20,9 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import jakarta.servlet.http.HttpServletRequest;
import org.jspecify.annotations.Nullable;
import org.springframework.http.server.PathContainer;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.servlet.HandlerExecutionChain;
import org.springframework.web.util.ServletRequestPathUtils;
@@ -56,9 +56,8 @@ class PathPatternMatchableHandlerMapping implements MatchableHandlerMapping {
this.parser = delegate.getPatternParser();
}
@Nullable
@Override
public RequestMatchResult match(HttpServletRequest request, String pattern) {
public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) {
PathPattern pathPattern = this.pathPatternCache.computeIfAbsent(pattern, value -> {
Assert.state(this.pathPatternCache.size() < MAX_PATTERNS, "Max size for pattern cache exceeded.");
return this.parser.parse(pattern);
@@ -67,9 +66,8 @@ class PathPatternMatchableHandlerMapping implements MatchableHandlerMapping {
return (pathPattern.matches(path) ? new RequestMatchResult(pathPattern, path) : null);
}
@Nullable
@Override
public HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
public @Nullable HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
return this.delegate.getHandler(request);
}

View File

@@ -18,8 +18,9 @@ package org.springframework.web.servlet.handler;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.http.server.PathContainer;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.PathMatcher;
import org.springframework.web.util.pattern.PathPattern;
@@ -34,21 +35,16 @@ import org.springframework.web.util.pattern.PathPattern;
*/
public class RequestMatchResult {
@Nullable
private final PathPattern pathPattern;
private final @Nullable PathPattern pathPattern;
@Nullable
private final PathContainer lookupPathContainer;
private final @Nullable PathContainer lookupPathContainer;
@Nullable
private final String pattern;
private final @Nullable String pattern;
@Nullable
private final String lookupPath;
private final @Nullable String lookupPath;
@Nullable
private final PathMatcher pathMatcher;
private final @Nullable PathMatcher pathMatcher;
/**

View File

@@ -24,8 +24,8 @@ import java.util.Properties;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.WebUtils;
@@ -49,22 +49,17 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
public static final String DEFAULT_EXCEPTION_ATTRIBUTE = "exception";
@Nullable
private Properties exceptionMappings;
private @Nullable Properties exceptionMappings;
@Nullable
private Class<?>[] excludedExceptions;
private Class<?> @Nullable [] excludedExceptions;
@Nullable
private String defaultErrorView;
private @Nullable String defaultErrorView;
@Nullable
private Integer defaultStatusCode;
private @Nullable Integer defaultStatusCode;
private final Map<String, Integer> statusCodes = new HashMap<>();
@Nullable
private String exceptionAttribute = DEFAULT_EXCEPTION_ATTRIBUTE;
private @Nullable String exceptionAttribute = DEFAULT_EXCEPTION_ATTRIBUTE;
/**
@@ -181,8 +176,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
* or {@code null} for default processing in the resolution chain
*/
@Override
@Nullable
protected ModelAndView doResolveException(
protected @Nullable ModelAndView doResolveException(
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) {
// Expose ModelAndView for chosen error view.
@@ -210,8 +204,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
* @param request current HTTP request (useful for obtaining metadata)
* @return the resolved view name, or {@code null} if excluded or none found
*/
@Nullable
protected String determineViewName(Exception ex, HttpServletRequest request) {
protected @Nullable String determineViewName(Exception ex, HttpServletRequest request) {
String viewName = null;
if (this.excludedExceptions != null) {
for (Class<?> excludedEx : this.excludedExceptions) {
@@ -241,8 +234,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
* @return the view name, or {@code null} if none found
* @see #setExceptionMappings
*/
@Nullable
protected String findMatchingViewName(Properties exceptionMappings, Exception ex) {
protected @Nullable String findMatchingViewName(Properties exceptionMappings, Exception ex) {
String viewName = null;
String dominantMapping = null;
int deepest = Integer.MAX_VALUE;
@@ -296,8 +288,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
* @see #setDefaultStatusCode
* @see #applyStatusCodeIfPossible
*/
@Nullable
protected Integer determineStatusCode(HttpServletRequest request, String viewName) {
protected @Nullable Integer determineStatusCode(HttpServletRequest request, String viewName) {
if (this.statusCodes.containsKey(viewName)) {
return this.statusCodes.get(viewName);
}

View File

@@ -19,8 +19,8 @@ package org.springframework.web.servlet.handler;
import jakarta.servlet.Servlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.HandlerAdapter;
import org.springframework.web.servlet.ModelAndView;
@@ -60,8 +60,7 @@ public class SimpleServletHandlerAdapter implements HandlerAdapter {
}
@Override
@Nullable
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
public @Nullable ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
((Servlet) handler).service(request, response);

View File

@@ -23,11 +23,11 @@ import jakarta.servlet.Servlet;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
import org.springframework.lang.Nullable;
import org.springframework.web.context.ServletConfigAware;
import org.springframework.web.context.ServletContextAware;
@@ -70,11 +70,9 @@ public class SimpleServletPostProcessor implements
private boolean useSharedServletConfig = true;
@Nullable
private ServletContext servletContext;
private @Nullable ServletContext servletContext;
@Nullable
private ServletConfig servletConfig;
private @Nullable ServletConfig servletConfig;
/**
@@ -143,8 +141,7 @@ public class SimpleServletPostProcessor implements
private final String servletName;
@Nullable
private final ServletContext servletContext;
private final @Nullable ServletContext servletContext;
public DelegatingServletConfig(String servletName, @Nullable ServletContext servletContext) {
this.servletName = servletName;
@@ -157,14 +154,12 @@ public class SimpleServletPostProcessor implements
}
@Override
@Nullable
public ServletContext getServletContext() {
public @Nullable ServletContext getServletContext() {
return this.servletContext;
}
@Override
@Nullable
public String getInitParameter(String paramName) {
public @Nullable String getInitParameter(String paramName) {
return null;
}

View File

@@ -21,8 +21,8 @@ import java.io.IOException;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.HandlerInterceptor;
/**
@@ -35,8 +35,7 @@ import org.springframework.web.servlet.HandlerInterceptor;
*/
public class UserRoleAuthorizationInterceptor implements HandlerInterceptor {
@Nullable
private String[] authorizedRoles;
private String @Nullable [] authorizedRoles;
/**

View File

@@ -18,8 +18,8 @@ package org.springframework.web.servlet.handler;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.context.request.AsyncWebRequestInterceptor;
import org.springframework.web.context.request.WebRequestInterceptor;

View File

@@ -2,9 +2,7 @@
* Provides standard HandlerMapping implementations,
* including abstract base classes for custom implementations.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.servlet.handler;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -18,7 +18,8 @@ package org.springframework.web.servlet.i18n;
import java.util.TimeZone;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.web.servlet.LocaleContextResolver;
/**
@@ -34,8 +35,7 @@ import org.springframework.web.servlet.LocaleContextResolver;
*/
public abstract class AbstractLocaleContextResolver extends AbstractLocaleResolver implements LocaleContextResolver {
@Nullable
private TimeZone defaultTimeZone;
private @Nullable TimeZone defaultTimeZone;
/**
@@ -50,8 +50,7 @@ public abstract class AbstractLocaleContextResolver extends AbstractLocaleResolv
* Get the default {@link TimeZone} that this resolver is supposed to fall
* back to, if any.
*/
@Nullable
public TimeZone getDefaultTimeZone() {
public @Nullable TimeZone getDefaultTimeZone() {
return this.defaultTimeZone;
}

View File

@@ -18,7 +18,8 @@ package org.springframework.web.servlet.i18n;
import java.util.Locale;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.web.servlet.LocaleResolver;
/**
@@ -32,8 +33,7 @@ import org.springframework.web.servlet.LocaleResolver;
*/
public abstract class AbstractLocaleResolver implements LocaleResolver {
@Nullable
private Locale defaultLocale;
private @Nullable Locale defaultLocale;
/**
@@ -48,8 +48,7 @@ public abstract class AbstractLocaleResolver implements LocaleResolver {
* Get the default {@link Locale} that this resolver is supposed to fall back
* to, if any.
*/
@Nullable
protected Locale getDefaultLocale() {
protected @Nullable Locale getDefaultLocale() {
return this.defaultLocale;
}

View File

@@ -23,8 +23,8 @@ import java.util.Locale;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
@@ -100,8 +100,7 @@ public class AcceptHeaderLocaleResolver extends AbstractLocaleResolver {
return (defaultLocale != null ? defaultLocale : requestLocale);
}
@Nullable
private Locale findSupportedLocale(HttpServletRequest request, List<Locale> supportedLocales) {
private @Nullable Locale findSupportedLocale(HttpServletRequest request, List<Locale> supportedLocales) {
Enumeration<Locale> requestLocales = request.getLocales();
Locale languageMatch = null;
while (requestLocales.hasMoreElements()) {

View File

@@ -26,12 +26,12 @@ 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.i18n.LocaleContext;
import org.springframework.context.i18n.TimeZoneAwareLocaleContext;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseCookie;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
@@ -297,13 +297,11 @@ public class CookieLocaleResolver extends AbstractLocaleContextResolver {
parseLocaleCookieIfNecessary(request);
return new TimeZoneAwareLocaleContext() {
@Override
@Nullable
public Locale getLocale() {
public @Nullable Locale getLocale() {
return (Locale) request.getAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME);
}
@Override
@Nullable
public TimeZone getTimeZone() {
public @Nullable TimeZone getTimeZone() {
return (TimeZone) request.getAttribute(TIME_ZONE_REQUEST_ATTRIBUTE_NAME);
}
};
@@ -395,8 +393,7 @@ public class CookieLocaleResolver extends AbstractLocaleContextResolver {
* @since 4.3
* @see StringUtils#parseLocale(String)
*/
@Nullable
protected Locale parseLocaleValue(String localeValue) {
protected @Nullable Locale parseLocaleValue(String localeValue) {
return StringUtils.parseLocale(localeValue);
}
@@ -442,8 +439,7 @@ public class CookieLocaleResolver extends AbstractLocaleContextResolver {
* @deprecated as of 6.0, in favor of {@link #setDefaultTimeZoneFunction(Function)}
*/
@Deprecated(since = "6.0")
@Nullable
protected TimeZone determineDefaultTimeZone(HttpServletRequest request) {
protected @Nullable TimeZone determineDefaultTimeZone(HttpServletRequest request) {
return this.defaultTimeZoneFunction.apply(request);
}

View File

@@ -21,10 +21,10 @@ import java.util.TimeZone;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.context.i18n.LocaleContext;
import org.springframework.context.i18n.TimeZoneAwareLocaleContext;
import org.springframework.lang.Nullable;
/**
* {@link org.springframework.web.servlet.LocaleResolver} implementation
@@ -83,13 +83,11 @@ public class FixedLocaleResolver extends AbstractLocaleContextResolver {
public LocaleContext resolveLocaleContext(HttpServletRequest request) {
return new TimeZoneAwareLocaleContext() {
@Override
@Nullable
public Locale getLocale() {
public @Nullable Locale getLocale() {
return getDefaultLocale();
}
@Override
@Nullable
public TimeZone getTimeZone() {
public @Nullable TimeZone getTimeZone() {
return getDefaultTimeZone();
}
};

View File

@@ -23,8 +23,8 @@ 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.lang.Nullable;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;
@@ -52,8 +52,7 @@ public class LocaleChangeInterceptor implements HandlerInterceptor {
private String paramName = DEFAULT_PARAM_NAME;
@Nullable
private String[] httpMethods;
private String @Nullable [] httpMethods;
private boolean ignoreInvalidLocale = false;
@@ -79,7 +78,7 @@ public class LocaleChangeInterceptor implements HandlerInterceptor {
* @param httpMethods the methods
* @since 4.2
*/
public void setHttpMethods(@Nullable String... httpMethods) {
public void setHttpMethods(String @Nullable ... httpMethods) {
this.httpMethods = httpMethods;
}
@@ -87,8 +86,7 @@ public class LocaleChangeInterceptor implements HandlerInterceptor {
* Return the configured HTTP methods.
* @since 4.2
*/
@Nullable
public String[] getHttpMethods() {
public String @Nullable [] getHttpMethods() {
return this.httpMethods;
}
@@ -161,8 +159,7 @@ public class LocaleChangeInterceptor implements HandlerInterceptor {
* @return the corresponding {@code Locale} instance
* @since 4.3
*/
@Nullable
protected Locale parseLocaleValue(String localeValue) {
protected @Nullable Locale parseLocaleValue(String localeValue) {
return StringUtils.parseLocale(localeValue);
}

View File

@@ -22,10 +22,10 @@ import java.util.function.Function;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.context.i18n.LocaleContext;
import org.springframework.context.i18n.TimeZoneAwareLocaleContext;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.util.WebUtils;
@@ -167,8 +167,7 @@ public class SessionLocaleResolver extends AbstractLocaleContextResolver {
return locale;
}
@Override
@Nullable
public TimeZone getTimeZone() {
public @Nullable TimeZone getTimeZone() {
TimeZone timeZone = (TimeZone) WebUtils.getSessionAttribute(request, timeZoneAttributeName);
if (timeZone == null) {
timeZone = defaultTimeZoneFunction.apply(request);
@@ -224,8 +223,7 @@ public class SessionLocaleResolver extends AbstractLocaleContextResolver {
* @deprecated as of 6.0, in favor of {@link #setDefaultTimeZoneFunction(Function)}
*/
@Deprecated(since = "6.0")
@Nullable
protected TimeZone determineDefaultTimeZone(HttpServletRequest request) {
protected @Nullable TimeZone determineDefaultTimeZone(HttpServletRequest request) {
return this.defaultTimeZoneFunction.apply(request);
}

View File

@@ -3,9 +3,7 @@
* Provides standard LocaleResolver implementations,
* and a HandlerInterceptor for locale changes.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.web.servlet.i18n;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -19,10 +19,10 @@ package org.springframework.web.servlet.mvc;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.support.WebContentGenerator;
import org.springframework.web.util.WebUtils;
@@ -151,8 +151,7 @@ public abstract class AbstractController extends WebContentGenerator implements
@Override
@Nullable
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
public @Nullable ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
if (HttpMethod.OPTIONS.matches(request.getMethod())) {
@@ -183,8 +182,7 @@ public abstract class AbstractController extends WebContentGenerator implements
* The contract is the same as for {@code handleRequest}.
* @see #handleRequest
*/
@Nullable
protected abstract ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
protected abstract @Nullable ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
throws Exception;
}

View File

@@ -18,8 +18,8 @@ package org.springframework.web.servlet.mvc;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.ModelAndView;
/**
@@ -121,7 +121,6 @@ public interface Controller {
* @return a ModelAndView to render, or {@code null} if handled directly
* @throws Exception in case of errors
*/
@Nullable
ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception;
@Nullable ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception;
}

View File

@@ -18,8 +18,8 @@ package org.springframework.web.servlet.mvc;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.servlet.HandlerAdapter;
import org.springframework.web.servlet.ModelAndView;
@@ -45,8 +45,7 @@ public class HttpRequestHandlerAdapter implements HandlerAdapter {
}
@Override
@Nullable
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
public @Nullable ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
((HttpRequestHandler) handler).handleRequest(request, response);

View File

@@ -18,11 +18,11 @@ package org.springframework.web.servlet.mvc;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.support.RequestContextUtils;
@@ -39,11 +39,9 @@ import org.springframework.web.servlet.support.RequestContextUtils;
*/
public class ParameterizableViewController extends AbstractController {
@Nullable
private Object view;
private @Nullable Object view;
@Nullable
private HttpStatusCode statusCode;
private @Nullable HttpStatusCode statusCode;
private boolean statusOnly;
@@ -66,8 +64,7 @@ public class ParameterizableViewController extends AbstractController {
* Return the name of the view to delegate to, or {@code null} if using a
* View instance.
*/
@Nullable
public String getViewName() {
public @Nullable String getViewName() {
if (this.view instanceof String viewName) {
if (getStatusCode() != null && getStatusCode().is3xxRedirection()) {
return viewName.startsWith("redirect:") ? viewName : "redirect:" + viewName;
@@ -93,8 +90,7 @@ public class ParameterizableViewController extends AbstractController {
* to be resolved by the DispatcherServlet via a ViewResolver.
* @since 4.1
*/
@Nullable
public View getView() {
public @Nullable View getView() {
return (this.view instanceof View v ? v : null);
}
@@ -117,8 +113,7 @@ public class ParameterizableViewController extends AbstractController {
* Return the configured HTTP status code or {@code null}.
* @since 4.1
*/
@Nullable
public HttpStatusCode getStatusCode() {
public @Nullable HttpStatusCode getStatusCode() {
return this.statusCode;
}
@@ -149,8 +144,7 @@ public class ParameterizableViewController extends AbstractController {
* @see #getViewName()
*/
@Override
@Nullable
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
protected @Nullable ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
throws Exception {
String viewName = getViewName();

View File

@@ -21,9 +21,9 @@ import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.WebUtils;
@@ -88,11 +88,9 @@ import org.springframework.web.util.WebUtils;
*/
public class ServletForwardingController extends AbstractController implements BeanNameAware {
@Nullable
private String servletName;
private @Nullable String servletName;
@Nullable
private String beanName;
private @Nullable String beanName;
public ServletForwardingController() {
@@ -119,8 +117,7 @@ public class ServletForwardingController extends AbstractController implements B
@Override
@Nullable
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
protected @Nullable ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
throws Exception {
ServletContext servletContext = getServletContext();

View File

@@ -24,11 +24,11 @@ import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.servlet.ModelAndView;
@@ -86,19 +86,15 @@ import org.springframework.web.servlet.ModelAndView;
public class ServletWrappingController extends AbstractController
implements BeanNameAware, InitializingBean, DisposableBean {
@Nullable
private Class<? extends Servlet> servletClass;
private @Nullable Class<? extends Servlet> servletClass;
@Nullable
private String servletName;
private @Nullable String servletName;
private Properties initParameters = new Properties();
@Nullable
private String beanName;
private @Nullable String beanName;
@Nullable
private Servlet servletInstance;
private @Nullable Servlet servletInstance;
public ServletWrappingController() {
@@ -159,8 +155,7 @@ public class ServletWrappingController extends AbstractController
* @see jakarta.servlet.Servlet#service(jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse)
*/
@Override
@Nullable
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
protected @Nullable ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Assert.state(this.servletInstance != null, "No Servlet instance");
@@ -189,14 +184,12 @@ public class ServletWrappingController extends AbstractController
private class DelegatingServletConfig implements ServletConfig {
@Override
@Nullable
public String getServletName() {
public @Nullable String getServletName() {
return servletName;
}
@Override
@Nullable
public ServletContext getServletContext() {
public @Nullable ServletContext getServletContext() {
return ServletWrappingController.this.getServletContext();
}

View File

@@ -18,8 +18,8 @@ package org.springframework.web.servlet.mvc;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.HandlerAdapter;
import org.springframework.web.servlet.ModelAndView;
@@ -44,8 +44,7 @@ public class SimpleControllerHandlerAdapter implements HandlerAdapter {
}
@Override
@Nullable
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
public @Nullable ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
return ((Controller) handler).handleRequest(request, response);

View File

@@ -20,8 +20,8 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import jakarta.servlet.http.HttpServletRequest;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.util.ServletRequestPathUtils;

View File

@@ -25,10 +25,10 @@ import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.http.CacheControl;
import org.springframework.http.server.PathContainer;
import org.springframework.lang.Nullable;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -250,8 +250,7 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle
* @return the matched {@code CacheControl}, or {@code null} if no match
* @since 5.3
*/
@Nullable
protected CacheControl lookupCacheControl(PathContainer path) {
protected @Nullable CacheControl lookupCacheControl(PathContainer path) {
for (Map.Entry<PathPattern, CacheControl> entry : this.cacheControlMappings.entrySet()) {
if (entry.getKey().matches(path)) {
return entry.getValue();
@@ -267,8 +266,7 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle
* @param lookupPath the path to match to
* @return the matched {@code CacheControl}, or {@code null} if no match
*/
@Nullable
protected CacheControl lookupCacheControl(String lookupPath) {
protected @Nullable CacheControl lookupCacheControl(String lookupPath) {
for (Map.Entry<PathPattern, CacheControl> entry : this.cacheControlMappings.entrySet()) {
if (this.pathMatcher.match(entry.getKey().getPatternString(), lookupPath)) {
return entry.getValue();
@@ -284,8 +282,7 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle
* @return the matched cacheSeconds, or {@code null} if there is no match
* @since 5.3
*/
@Nullable
protected Integer lookupCacheSeconds(PathContainer path) {
protected @Nullable Integer lookupCacheSeconds(PathContainer path) {
for (Map.Entry<PathPattern, Integer> entry : this.cacheMappings.entrySet()) {
if (entry.getKey().matches(path)) {
return entry.getValue();
@@ -301,8 +298,7 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle
* @param lookupPath the path to match to
* @return the matched cacheSeconds, or {@code null} if there is no match
*/
@Nullable
protected Integer lookupCacheSeconds(String lookupPath) {
protected @Nullable Integer lookupCacheSeconds(String lookupPath) {
for (Map.Entry<PathPattern, Integer> entry : this.cacheMappings.entrySet()) {
if (this.pathMatcher.match(entry.getKey().getPatternString(), lookupPath)) {
return entry.getValue();

View File

@@ -18,7 +18,8 @@ package org.springframework.web.servlet.mvc.annotation;
import java.lang.reflect.Method;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.ui.ExtendedModelMap;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.servlet.ModelAndView;

View File

@@ -20,12 +20,12 @@ import java.io.IOException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jspecify.annotations.Nullable;
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceAware;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.server.ResponseStatusException;
@@ -56,8 +56,7 @@ import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
*/
public class ResponseStatusExceptionResolver extends AbstractHandlerExceptionResolver implements MessageSourceAware {
@Nullable
private MessageSource messageSource;
private @Nullable MessageSource messageSource;
@Override
@@ -67,8 +66,7 @@ public class ResponseStatusExceptionResolver extends AbstractHandlerExceptionRes
@Override
@Nullable
protected ModelAndView doResolveException(
protected @Nullable ModelAndView doResolveException(
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) {
try {

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