Introduce null-safety of Spring Framework API
This commit introduces 2 new @Nullable and @NonNullApi annotations that leverage JSR 305 (dormant but available via Findbugs jsr305 dependency and already used by libraries like OkHttp) meta-annotations to specify explicitly null-safety of Spring Framework parameters and return values. In order to avoid adding too much annotations, the default is set at package level with @NonNullApi and @Nullable annotations are added when needed at parameter or return value level. These annotations are intended to be used on Spring Framework itself but also by other Spring projects. @Nullable annotations have been introduced based on Javadoc and search of patterns like "return null;". It is expected that nullability of Spring Framework API will be polished with complementary commits. In practice, this will make the whole Spring Framework API null-safe for Kotlin projects (when KT-10942 will be fixed) since Kotlin will be able to leverage these annotations to know if a parameter or a return value is nullable or not. But this is also useful for Java developers as well since IntelliJ IDEA, for example, also understands these annotations to generate warnings when unsafe nullable usages are detected. Issue: SPR-15540
This commit is contained in:
@@ -28,6 +28,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -46,6 +47,7 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.ui.context.ThemeSource;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -767,6 +769,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
* @return the ThemeSource, if any
|
||||
* @see #getWebApplicationContext()
|
||||
*/
|
||||
@Nullable
|
||||
public final ThemeSource getThemeSource() {
|
||||
if (getWebApplicationContext() instanceof ThemeSource) {
|
||||
return (ThemeSource) getWebApplicationContext();
|
||||
@@ -781,6 +784,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() {
|
||||
return this.multipartResolver;
|
||||
}
|
||||
@@ -1151,6 +1155,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 {
|
||||
for (HandlerMapping hm : this.handlerMappings) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
@@ -1213,8 +1218,9 @@ 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,
|
||||
Object handler, Exception ex) throws Exception {
|
||||
@Nullable Object handler, Exception ex) throws Exception {
|
||||
|
||||
// Check registered HandlerExceptionResolvers...
|
||||
ModelAndView exMv = null;
|
||||
@@ -1300,6 +1306,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 {
|
||||
return this.viewNameTranslator.getViewName(request);
|
||||
}
|
||||
@@ -1318,6 +1325,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
* (typically in case of problems creating an actual View object)
|
||||
* @see ViewResolver#resolveViewName
|
||||
*/
|
||||
@Nullable
|
||||
protected View resolveViewName(String viewName, Map<String, Object> model, Locale locale,
|
||||
HttpServletRequest request) throws Exception {
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.web.servlet;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -67,6 +68,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() {
|
||||
return this.targetRequestPath;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.web.servlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A strategy interface for retrieving and saving FlashMap instances.
|
||||
* See {@link FlashMap} for a general overview of flash attributes.
|
||||
@@ -40,6 +42,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);
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.security.Principal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -43,6 +44,7 @@ import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -321,6 +323,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
|
||||
/**
|
||||
* Return the custom WebApplicationContext id, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public String getContextId() {
|
||||
return this.contextId;
|
||||
}
|
||||
@@ -353,6 +356,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
|
||||
/**
|
||||
* Return the explicit context config location, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public String getContextConfigLocation() {
|
||||
return this.contextConfigLocation;
|
||||
}
|
||||
@@ -578,6 +582,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() {
|
||||
String attrName = getContextAttribute();
|
||||
if (attrName == null) {
|
||||
@@ -606,7 +611,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
|
||||
* @return the WebApplicationContext for this servlet
|
||||
* @see org.springframework.web.context.support.XmlWebApplicationContext
|
||||
*/
|
||||
protected WebApplicationContext createWebApplicationContext(ApplicationContext parent) {
|
||||
protected WebApplicationContext createWebApplicationContext(@Nullable ApplicationContext parent) {
|
||||
Class<?> contextClass = getContextClass();
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Servlet with name '" + getServletName() +
|
||||
@@ -673,7 +678,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
|
||||
* @see org.springframework.web.context.support.XmlWebApplicationContext
|
||||
* @see #createWebApplicationContext(ApplicationContext)
|
||||
*/
|
||||
protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) {
|
||||
protected WebApplicationContext createWebApplicationContext(@Nullable WebApplicationContext parent) {
|
||||
return createWebApplicationContext((ApplicationContext) parent);
|
||||
}
|
||||
|
||||
@@ -1007,6 +1012,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) {
|
||||
return new SimpleLocaleContext(request.getLocale());
|
||||
}
|
||||
@@ -1022,6 +1028,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, HttpServletResponse response, RequestAttributes previousAttributes) {
|
||||
|
||||
@@ -1080,6 +1087,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
|
||||
* @return the username, or {@code null} if none found
|
||||
* @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
|
||||
*/
|
||||
@Nullable
|
||||
protected String getUsernameForRequest(HttpServletRequest request) {
|
||||
Principal userPrincipal = request.getUserPrincipal();
|
||||
return (userPrincipal != null ? userPrincipal.getName() : null);
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.web.servlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* MVC framework SPI, allowing parameterization of the core MVC workflow.
|
||||
*
|
||||
@@ -72,6 +74,7 @@ public interface HandlerAdapter {
|
||||
* @return ModelAndView object with the name of the view and the required
|
||||
* model data, or {@code null} if the request has been handled directly
|
||||
*/
|
||||
@Nullable
|
||||
ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.web.servlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by objects that can resolve exceptions thrown during
|
||||
* handler mapping or execution, in the typical case to error views. Implementors are
|
||||
@@ -47,7 +49,8 @@ public interface HandlerExceptionResolver {
|
||||
* @return a corresponding {@code ModelAndView} to forward to, or {@code null}
|
||||
* for default processing
|
||||
*/
|
||||
@Nullable
|
||||
ModelAndView resolveException(
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex);
|
||||
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,12 +18,14 @@ package org.springframework.web.servlet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -81,6 +83,7 @@ public class HandlerExecutionChain {
|
||||
* Return the handler object to execute.
|
||||
* @return the handler object (may be {@code null})
|
||||
*/
|
||||
@Nullable
|
||||
public Object getHandler() {
|
||||
return this.handler;
|
||||
}
|
||||
@@ -111,6 +114,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() {
|
||||
if (this.interceptors == null && this.interceptorList != null) {
|
||||
this.interceptors = this.interceptorList.toArray(new HandlerInterceptor[this.interceptorList.size()]);
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.servlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
|
||||
/**
|
||||
@@ -120,7 +121,7 @@ public interface HandlerInterceptor {
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
default void postHandle(
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView)
|
||||
throws Exception {
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.web.servlet;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by objects that define a mapping between
|
||||
* requests and handler objects.
|
||||
@@ -126,6 +128,7 @@ 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;
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.servlet;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
@@ -40,6 +41,7 @@ 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;
|
||||
@@ -202,6 +204,7 @@ public abstract class HttpServletBean extends HttpServlet implements Environment
|
||||
* @see #getServletConfig()
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public final String getServletName() {
|
||||
return (getServletConfig() != null ? getServletConfig().getServletName() : null);
|
||||
}
|
||||
@@ -212,6 +215,7 @@ public abstract class HttpServletBean extends HttpServlet implements Environment
|
||||
* @see #getServletConfig()
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public final ServletContext getServletContext() {
|
||||
return (getServletConfig() != null ? getServletConfig().getServletContext() : null);
|
||||
}
|
||||
|
||||
@@ -17,10 +17,12 @@
|
||||
package org.springframework.web.servlet;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.context.i18n.LocaleContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Extension of {@link LocaleResolver}, adding support for a rich locale context
|
||||
@@ -68,6 +70,6 @@ public interface LocaleContextResolver extends LocaleResolver {
|
||||
* @see org.springframework.context.i18n.SimpleLocaleContext
|
||||
* @see org.springframework.context.i18n.SimpleTimeZoneAwareLocaleContext
|
||||
*/
|
||||
void setLocaleContext(HttpServletRequest request, HttpServletResponse response, LocaleContext localeContext);
|
||||
void setLocaleContext(HttpServletRequest request, HttpServletResponse response, @Nullable LocaleContext localeContext);
|
||||
|
||||
}
|
||||
|
||||
@@ -17,9 +17,12 @@
|
||||
package org.springframework.web.servlet;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface for web-based locale resolution strategies that allows for
|
||||
* both locale resolution via the request and locale modification via
|
||||
@@ -66,6 +69,6 @@ public interface LocaleResolver {
|
||||
* @throws UnsupportedOperationException if the LocaleResolver
|
||||
* implementation does not support dynamic changing of the locale
|
||||
*/
|
||||
void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale);
|
||||
void setLocale(HttpServletRequest request, HttpServletResponse response, @Nullable Locale locale);
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.servlet;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -96,7 +97,7 @@ public class ModelAndView {
|
||||
* (Objects). Model entries may not be {@code null}, but the
|
||||
* model Map may be {@code null} if there is no model data.
|
||||
*/
|
||||
public ModelAndView(String viewName, Map<String, ?> model) {
|
||||
public ModelAndView(String viewName, @Nullable Map<String, ?> model) {
|
||||
this.view = viewName;
|
||||
if (model != null) {
|
||||
getModelMap().addAllAttributes(model);
|
||||
@@ -113,7 +114,7 @@ public class ModelAndView {
|
||||
* (Objects). Model entries may not be {@code null}, but the
|
||||
* model Map may be {@code null} if there is no model data.
|
||||
*/
|
||||
public ModelAndView(View view, Map<String, ?> model) {
|
||||
public ModelAndView(View view, @Nullable Map<String, ?> model) {
|
||||
this.view = view;
|
||||
if (model != null) {
|
||||
getModelMap().addAllAttributes(model);
|
||||
@@ -144,7 +145,7 @@ public class ModelAndView {
|
||||
* (to be set just prior to View rendering)
|
||||
* @since 4.3
|
||||
*/
|
||||
public ModelAndView(String viewName, Map<String, ?> model, HttpStatus status) {
|
||||
public ModelAndView(String viewName, @Nullable Map<String, ?> model, HttpStatus status) {
|
||||
this.view = viewName;
|
||||
if (model != null) {
|
||||
getModelMap().addAllAttributes(model);
|
||||
@@ -189,6 +190,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() {
|
||||
return (this.view instanceof String ? (String) this.view : null);
|
||||
}
|
||||
@@ -205,6 +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() {
|
||||
return (this.view instanceof View ? (View) this.view : null);
|
||||
}
|
||||
@@ -230,6 +233,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() {
|
||||
return this.model;
|
||||
}
|
||||
@@ -265,6 +269,7 @@ public class ModelAndView {
|
||||
* Return the configured HTTP status for the response, if any.
|
||||
* @since 4.3
|
||||
*/
|
||||
@Nullable
|
||||
public HttpStatus getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.web.servlet;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Strategy interface for translating an incoming
|
||||
* {@link javax.servlet.http.HttpServletRequest} into a
|
||||
@@ -36,6 +38,7 @@ 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;
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.PathMatcher;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -235,6 +236,7 @@ public class ResourceServlet extends HttpServletBean {
|
||||
* @return the URL of the target resource, or {@code null} if none found
|
||||
* @see #RESOURCE_PARAM_NAME
|
||||
*/
|
||||
@Nullable
|
||||
protected String determineResourceUrl(HttpServletRequest request) {
|
||||
return request.getParameter(RESOURCE_PARAM_NAME);
|
||||
}
|
||||
|
||||
@@ -17,10 +17,12 @@
|
||||
package org.springframework.web.servlet;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* MVC View for a web interaction. Implementations are responsible for rendering
|
||||
@@ -73,6 +75,7 @@ public interface View {
|
||||
* @return the content type String (optionally including a character set),
|
||||
* or {@code null} if not predetermined.
|
||||
*/
|
||||
@Nullable
|
||||
String getContentType();
|
||||
|
||||
/**
|
||||
@@ -87,6 +90,6 @@ public interface View {
|
||||
* @param response HTTP response we are building
|
||||
* @throws Exception if rendering failed
|
||||
*/
|
||||
void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception;
|
||||
void render(@Nullable Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.web.servlet;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by objects that can resolve views by name.
|
||||
*
|
||||
@@ -50,6 +52,7 @@ 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;
|
||||
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ 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.xml.SourceHttpMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
@@ -355,6 +356,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
return conversionServiceRef;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RuntimeBeanReference getValidator(Element element, Object source, ParserContext parserContext) {
|
||||
if (element.hasAttribute("validator")) {
|
||||
return new RuntimeBeanReference(element.getAttribute("validator"));
|
||||
@@ -450,6 +452,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
return props;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RuntimeBeanReference getMessageCodesResolver(Element element) {
|
||||
if (element.hasAttribute("message-codes-resolver")) {
|
||||
return new RuntimeBeanReference(element.getAttribute("message-codes-resolver"));
|
||||
@@ -464,6 +467,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
return (asyncElement != null) ? asyncElement.getAttribute("default-timeout") : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RuntimeBeanReference getAsyncExecutor(Element element) {
|
||||
Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support");
|
||||
if (asyncElement != null) {
|
||||
@@ -508,6 +512,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
return interceptors;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ManagedList<?> getArgumentResolvers(Element element, ParserContext parserContext) {
|
||||
Element resolversElement = DomUtils.getChildElementByTagName(element, "argument-resolvers");
|
||||
if (resolversElement != null) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||
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.PathMatcher;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
@@ -183,6 +184,7 @@ abstract class MvcNamespaceUtils {
|
||||
* with the {@code annotation-driven} element.
|
||||
* @return a bean definition, bean reference, or null.
|
||||
*/
|
||||
@Nullable
|
||||
public static Object getContentNegotiationManager(ParserContext context) {
|
||||
String name = AnnotationDrivenBeanDefinitionParser.HANDLER_MAPPING_BEAN_NAME;
|
||||
if (context.getRegistry().containsBeanDefinition(name)) {
|
||||
|
||||
@@ -18,8 +18,10 @@ package org.springframework.web.servlet.config.annotation;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.HttpRequestHandler;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
@@ -80,6 +82,7 @@ public class DefaultServletHandlerConfigurer {
|
||||
* {@link DefaultServletHttpRequestHandler} instance mapped to {@code "/**"}; or {@code null} if
|
||||
* default servlet handling was not been enabled.
|
||||
*/
|
||||
@Nullable
|
||||
protected AbstractHandlerMapping getHandlerMapping() {
|
||||
if (handler == null) {
|
||||
return null;
|
||||
|
||||
@@ -21,10 +21,12 @@ import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.springframework.beans.factory.BeanInitializationException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.HttpRequestHandler;
|
||||
import org.springframework.web.accept.ContentNegotiationManager;
|
||||
@@ -131,6 +133,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() {
|
||||
if (this.registrations.isEmpty()) {
|
||||
return null;
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.servlet.handler.AbstractHandlerMapping;
|
||||
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
||||
|
||||
@@ -105,6 +106,7 @@ public class ViewControllerRegistry {
|
||||
* Return the {@code HandlerMapping} that contains the registered view
|
||||
* controller mappings, or {@code null} for no registrations.
|
||||
*/
|
||||
@Nullable
|
||||
protected AbstractHandlerMapping getHandlerMapping() {
|
||||
if (this.registrations.isEmpty() && this.redirectRegistrations.isEmpty()) {
|
||||
return null;
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@@ -56,6 +57,7 @@ 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.xml.SourceHttpMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.PathMatcher;
|
||||
@@ -584,6 +586,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||
/**
|
||||
* Override this method to provide a custom {@link MessageCodesResolver}.
|
||||
*/
|
||||
@Nullable
|
||||
protected MessageCodesResolver getMessageCodesResolver() {
|
||||
return null;
|
||||
}
|
||||
@@ -646,6 +649,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||
/**
|
||||
* Override this method to provide a custom {@link Validator}.
|
||||
*/
|
||||
@Nullable
|
||||
protected Validator getValidator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ 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.method.support.HandlerMethodArgumentResolver;
|
||||
@@ -214,6 +215,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() {
|
||||
return null;
|
||||
}
|
||||
@@ -223,6 +225,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() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Annotation-based setup for Spring MVC.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.servlet.config.annotation;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Defines the XML configuration namespace for Spring MVC.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.servlet.config;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.servlet.handler;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
||||
import org.springframework.context.ApplicationContextException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -96,6 +97,7 @@ public abstract class AbstractDetectingUrlHandlerMapping extends AbstractUrlHand
|
||||
* @return the URLs determined for the bean,
|
||||
* or {@code null} or an empty array if none
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract String[] determineUrlsForHandler(String beanName);
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@@ -157,7 +158,7 @@ public abstract class AbstractHandlerExceptionResolver implements HandlerExcepti
|
||||
* @see #setMappedHandlers
|
||||
* @see #setMappedHandlerClasses
|
||||
*/
|
||||
protected boolean shouldApplyTo(HttpServletRequest request, Object handler) {
|
||||
protected boolean shouldApplyTo(HttpServletRequest request, @Nullable Object handler) {
|
||||
if (handler != null) {
|
||||
if (this.mappedHandlers != null && this.mappedHandlers.contains(handler)) {
|
||||
return true;
|
||||
@@ -239,7 +240,8 @@ public abstract class AbstractHandlerExceptionResolver implements HandlerExcepti
|
||||
* @param ex the exception that got thrown during handler execution
|
||||
* @return a corresponding {@code ModelAndView} to forward to, or {@code null} for default processing
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract ModelAndView doResolveException(HttpServletRequest request,
|
||||
HttpServletResponse response, Object handler, Exception ex);
|
||||
HttpServletResponse response, @Nullable Object handler, Exception ex);
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.PathMatcher;
|
||||
@@ -111,6 +112,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
|
||||
* Return the default handler for this handler mapping,
|
||||
* or {@code null} if none.
|
||||
*/
|
||||
@Nullable
|
||||
public Object getDefaultHandler() {
|
||||
return this.defaultHandler;
|
||||
}
|
||||
@@ -197,7 +199,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
|
||||
* @see org.springframework.web.servlet.HandlerInterceptor
|
||||
* @see org.springframework.web.context.request.WebRequestInterceptor
|
||||
*/
|
||||
public void setInterceptors(Object... interceptors) {
|
||||
public void setInterceptors(@Nullable Object... interceptors) {
|
||||
this.interceptors.addAll(Arrays.asList(interceptors));
|
||||
}
|
||||
|
||||
@@ -320,6 +322,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
|
||||
* Return the adapted interceptors as {@link HandlerInterceptor} array.
|
||||
* @return the array of {@link HandlerInterceptor}s, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
protected final HandlerInterceptor[] getAdaptedInterceptors() {
|
||||
int count = this.adaptedInterceptors.size();
|
||||
return (count > 0 ? this.adaptedInterceptors.toArray(new HandlerInterceptor[count]) : null);
|
||||
@@ -329,6 +332,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() {
|
||||
List<MappedInterceptor> mappedInterceptors = new ArrayList<>();
|
||||
for (HandlerInterceptor interceptor : this.adaptedInterceptors) {
|
||||
@@ -389,6 +393,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;
|
||||
|
||||
/**
|
||||
@@ -437,6 +442,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
|
||||
* @return the CORS configuration for the handler or {@code null}.
|
||||
* @since 4.2
|
||||
*/
|
||||
@Nullable
|
||||
protected CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request) {
|
||||
if (handler instanceof HandlerExecutionChain) {
|
||||
handler = ((HandlerExecutionChain) handler).getHandler();
|
||||
@@ -460,7 +466,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
|
||||
* @since 4.2
|
||||
*/
|
||||
protected HandlerExecutionChain getCorsHandlerExecutionChain(HttpServletRequest request,
|
||||
HandlerExecutionChain chain, CorsConfiguration config) {
|
||||
HandlerExecutionChain chain, @Nullable CorsConfiguration config) {
|
||||
|
||||
if (CorsUtils.isPreFlightRequest(request)) {
|
||||
HandlerInterceptor[] interceptors = chain.getInterceptors();
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.servlet.handler;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@@ -73,7 +74,8 @@ 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(
|
||||
HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod, Exception ex);
|
||||
HttpServletRequest request, HttpServletResponse response, @Nullable HandlerMethod handlerMethod, Exception ex);
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@@ -35,6 +36,7 @@ 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;
|
||||
@@ -118,6 +120,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
|
||||
/**
|
||||
* Return the configured naming strategy or {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
public HandlerMethodMappingNamingStrategy<T> getNamingStrategy() {
|
||||
return this.namingStrategy;
|
||||
}
|
||||
@@ -142,6 +145,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) {
|
||||
return this.mappingRegistry.getHandlerMethodsByMappingName(mappingName);
|
||||
}
|
||||
@@ -286,6 +290,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) {
|
||||
return null;
|
||||
}
|
||||
@@ -336,6 +341,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 {
|
||||
List<Match> matches = new ArrayList<Match>();
|
||||
List<T> directPathMatches = this.mappingRegistry.getMappingsByUrl(lookupPath);
|
||||
@@ -401,6 +407,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)
|
||||
throws Exception {
|
||||
|
||||
@@ -441,6 +448,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);
|
||||
|
||||
/**
|
||||
@@ -455,6 +463,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);
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,10 +22,12 @@ import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.servlet.HandlerExecutionChain;
|
||||
@@ -73,6 +75,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() {
|
||||
return this.rootHandler;
|
||||
}
|
||||
@@ -113,6 +116,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 {
|
||||
String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
|
||||
Object handler = lookupHandler(lookupPath, request);
|
||||
@@ -158,6 +162,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
|
||||
* @see #exposePathWithinMapping
|
||||
* @see org.springframework.util.AntPathMatcher
|
||||
*/
|
||||
@Nullable
|
||||
protected Object lookupHandler(String urlPath, HttpServletRequest request) throws Exception {
|
||||
// Direct match?
|
||||
Object handler = this.handlerMap.get(urlPath);
|
||||
@@ -255,7 +260,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
|
||||
* @return the final handler object
|
||||
*/
|
||||
protected Object buildPathExposingHandler(Object rawHandler, String bestMatchingPattern,
|
||||
String pathWithinMapping, Map<String, String> uriTemplateVariables) {
|
||||
String pathWithinMapping, @Nullable Map<String, String> uriTemplateVariables) {
|
||||
|
||||
HandlerExecutionChain chain = new HandlerExecutionChain(rawHandler);
|
||||
chain.addInterceptor(new PathExposingHandlerInterceptor(bestMatchingPattern, pathWithinMapping));
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
|
||||
@@ -30,6 +31,7 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
@@ -125,6 +127,7 @@ public class HandlerMappingIntrospector implements CorsConfigurationSource {
|
||||
* @return the resolved matcher, or {@code null}
|
||||
* @throws Exception if any of the HandlerMapping's raise an exception
|
||||
*/
|
||||
@Nullable
|
||||
public MatchableHandlerMapping getMatchableHandlerMapping(HttpServletRequest request) throws Exception {
|
||||
HttpServletRequest wrapper = new RequestAttributeChangeIgnoringWrapper(request);
|
||||
for (HandlerMapping handlerMapping : this.handlerMappings) {
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.servlet.handler;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.PathMatcher;
|
||||
import org.springframework.web.context.request.WebRequestInterceptor;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
@@ -57,7 +58,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
|
||||
* @param includePatterns the path patterns to map with a {@code null} value matching to all paths
|
||||
* @param interceptor the HandlerInterceptor instance to map to the given patterns
|
||||
*/
|
||||
public MappedInterceptor(String[] includePatterns, HandlerInterceptor interceptor) {
|
||||
public MappedInterceptor(@Nullable String[] includePatterns, HandlerInterceptor interceptor) {
|
||||
this(includePatterns, null, interceptor);
|
||||
}
|
||||
|
||||
@@ -67,7 +68,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
|
||||
* @param excludePatterns the path patterns to exclude
|
||||
* @param interceptor the HandlerInterceptor instance to map to the given patterns
|
||||
*/
|
||||
public MappedInterceptor(String[] includePatterns, String[] excludePatterns, HandlerInterceptor interceptor) {
|
||||
public MappedInterceptor(@Nullable String[] includePatterns, String[] excludePatterns, HandlerInterceptor interceptor) {
|
||||
this.includePatterns = includePatterns;
|
||||
this.excludePatterns = excludePatterns;
|
||||
this.interceptor = interceptor;
|
||||
@@ -79,7 +80,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
|
||||
* @param includePatterns the path patterns to map with a {@code null} value matching to all paths
|
||||
* @param interceptor the WebRequestInterceptor instance to map to the given patterns
|
||||
*/
|
||||
public MappedInterceptor(String[] includePatterns, WebRequestInterceptor interceptor) {
|
||||
public MappedInterceptor(@Nullable String[] includePatterns, WebRequestInterceptor interceptor) {
|
||||
this(includePatterns, null, interceptor);
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
|
||||
* @param includePatterns the path patterns to map with a {@code null} value matching to all paths
|
||||
* @param interceptor the WebRequestInterceptor instance to map to the given patterns
|
||||
*/
|
||||
public MappedInterceptor(String[] includePatterns, String[] excludePatterns, WebRequestInterceptor interceptor) {
|
||||
public MappedInterceptor(@Nullable String[] includePatterns, String[] excludePatterns, WebRequestInterceptor interceptor) {
|
||||
this(includePatterns, excludePatterns, new WebRequestHandlerInterceptorAdapter(interceptor));
|
||||
}
|
||||
|
||||
@@ -109,6 +110,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
|
||||
/**
|
||||
* The configured PathMatcher, or {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
public PathMatcher getPathMatcher() {
|
||||
return this.pathMatcher;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.web.servlet.handler;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
|
||||
/**
|
||||
@@ -37,6 +38,7 @@ 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);
|
||||
|
||||
}
|
||||
|
||||
@@ -21,9 +21,11 @@ import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
@@ -153,7 +155,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
|
||||
* for not exposing an exception attribute at all.
|
||||
* @see #DEFAULT_EXCEPTION_ATTRIBUTE
|
||||
*/
|
||||
public void setExceptionAttribute(String exceptionAttribute) {
|
||||
public void setExceptionAttribute(@Nullable String exceptionAttribute) {
|
||||
this.exceptionAttribute = exceptionAttribute;
|
||||
}
|
||||
|
||||
@@ -201,6 +203,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) {
|
||||
String viewName = null;
|
||||
if (this.excludedExceptions != null) {
|
||||
@@ -232,6 +235,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) {
|
||||
String viewName = null;
|
||||
String dominantMapping = null;
|
||||
@@ -287,6 +291,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
|
||||
* @see #setDefaultStatusCode
|
||||
* @see #applyStatusCodeIfPossible
|
||||
*/
|
||||
@Nullable
|
||||
protected Integer determineStatusCode(HttpServletRequest request, String viewName) {
|
||||
if (this.statusCodes.containsKey(viewName)) {
|
||||
return this.statusCodes.get(viewName);
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* Provides standard HandlerMapping implementations,
|
||||
* including abstract base classes for custom implementations.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.servlet.handler;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.context.i18n.SimpleLocaleContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.servlet.LocaleContextResolver;
|
||||
|
||||
/**
|
||||
@@ -51,6 +52,7 @@ public abstract class AbstractLocaleContextResolver extends AbstractLocaleResolv
|
||||
/**
|
||||
* Return the default TimeZone that this resolver is supposed to fall back to, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public TimeZone getDefaultTimeZone() {
|
||||
return this.defaultTimeZone;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.web.servlet.i18n;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
|
||||
/**
|
||||
@@ -43,6 +44,7 @@ public abstract class AbstractLocaleResolver implements LocaleResolver {
|
||||
/**
|
||||
* Return the default Locale that this resolver is supposed to fall back to, if any.
|
||||
*/
|
||||
@Nullable
|
||||
protected Locale getDefaultLocale() {
|
||||
return this.defaultLocale;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Locale;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
|
||||
/**
|
||||
@@ -84,6 +85,7 @@ public class AcceptHeaderLocaleResolver implements LocaleResolver {
|
||||
* The configured default locale, if any.
|
||||
* @since 4.3
|
||||
*/
|
||||
@Nullable
|
||||
public Locale getDefaultLocale() {
|
||||
return this.defaultLocale;
|
||||
}
|
||||
@@ -111,6 +113,7 @@ public class AcceptHeaderLocaleResolver implements LocaleResolver {
|
||||
return (supportedLocales.isEmpty() || supportedLocales.contains(locale));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Locale findSupportedLocale(HttpServletRequest request) {
|
||||
Enumeration<Locale> requestLocales = request.getLocales();
|
||||
while (requestLocales.hasMoreElements()) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.web.servlet.i18n;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -25,6 +26,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.context.i18n.LocaleContext;
|
||||
import org.springframework.context.i18n.SimpleLocaleContext;
|
||||
import org.springframework.context.i18n.TimeZoneAwareLocaleContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.LocaleContextResolver;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
@@ -131,6 +133,7 @@ public class CookieLocaleResolver extends CookieGenerator implements LocaleConte
|
||||
* Return the fixed Locale that this resolver will return if no cookie found,
|
||||
* if any.
|
||||
*/
|
||||
@Nullable
|
||||
protected Locale getDefaultLocale() {
|
||||
return this.defaultLocale;
|
||||
}
|
||||
@@ -148,6 +151,7 @@ public class CookieLocaleResolver extends CookieGenerator implements LocaleConte
|
||||
* if any.
|
||||
* @since 4.0
|
||||
*/
|
||||
@Nullable
|
||||
protected TimeZone getDefaultTimeZone() {
|
||||
return this.defaultTimeZone;
|
||||
}
|
||||
@@ -283,6 +287,7 @@ public class CookieLocaleResolver extends CookieGenerator implements LocaleConte
|
||||
* @see #setDefaultLocale
|
||||
* @see javax.servlet.http.HttpServletRequest#getLocale()
|
||||
*/
|
||||
@Nullable
|
||||
protected Locale determineDefaultLocale(HttpServletRequest request) {
|
||||
Locale defaultLocale = getDefaultLocale();
|
||||
if (defaultLocale == null) {
|
||||
@@ -300,6 +305,7 @@ public class CookieLocaleResolver extends CookieGenerator implements LocaleConte
|
||||
* @return the default time zone (or {@code null} if none defined)
|
||||
* @see #setDefaultTimeZone
|
||||
*/
|
||||
@Nullable
|
||||
protected TimeZone determineDefaultTimeZone(HttpServletRequest request) {
|
||||
return getDefaultTimeZone();
|
||||
}
|
||||
|
||||
@@ -18,11 +18,13 @@ package org.springframework.web.servlet.i18n;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.context.i18n.LocaleContext;
|
||||
import org.springframework.context.i18n.TimeZoneAwareLocaleContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
@@ -178,6 +180,7 @@ public class SessionLocaleResolver extends AbstractLocaleContextResolver {
|
||||
* @return the default time zone (or {@code null} if none defined)
|
||||
* @see #setDefaultTimeZone
|
||||
*/
|
||||
@Nullable
|
||||
protected TimeZone determineDefaultTimeZone(HttpServletRequest request) {
|
||||
return getDefaultTimeZone();
|
||||
}
|
||||
|
||||
@@ -3,4 +3,7 @@
|
||||
* Provides standard LocaleResolver implementations,
|
||||
* and a HandlerInterceptor for locale changes.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.servlet.i18n;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
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;
|
||||
@@ -179,6 +180,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)
|
||||
throws Exception;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.servlet.mvc;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
@@ -119,6 +120,7 @@ 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;
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.View;
|
||||
import org.springframework.web.servlet.support.RequestContextUtils;
|
||||
@@ -62,6 +63,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() {
|
||||
return (this.view instanceof String ? (String) this.view : null);
|
||||
}
|
||||
@@ -80,6 +82,7 @@ public class ParameterizableViewController extends AbstractController {
|
||||
* to be resolved by the DispatcherServlet via a ViewResolver.
|
||||
* @since 4.1
|
||||
*/
|
||||
@Nullable
|
||||
public View getView() {
|
||||
return (this.view instanceof View ? (View) this.view : null);
|
||||
}
|
||||
@@ -103,6 +106,7 @@ public class ParameterizableViewController extends AbstractController {
|
||||
* Return the configured HTTP status code or {@code null}.
|
||||
* @since 4.1
|
||||
*/
|
||||
@Nullable
|
||||
public HttpStatus getStatusCode() {
|
||||
return this.statusCode;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.http.CacheControl;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.PathMatcher;
|
||||
@@ -214,6 +215,7 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle
|
||||
* @return the associated {@code CacheControl}, or {@code null} if not found
|
||||
* @see org.springframework.util.AntPathMatcher
|
||||
*/
|
||||
@Nullable
|
||||
protected CacheControl lookupCacheControl(String urlPath) {
|
||||
// Direct match?
|
||||
CacheControl cacheControl = this.cacheControlMappings.get(urlPath);
|
||||
@@ -238,6 +240,7 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle
|
||||
* @return the cacheSeconds integer value, or {@code null} if not found
|
||||
* @see org.springframework.util.AntPathMatcher
|
||||
*/
|
||||
@Nullable
|
||||
protected Integer lookupCacheSeconds(String urlPath) {
|
||||
// Direct match?
|
||||
Integer cacheSeconds = this.cacheMappings.get(urlPath);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.web.servlet.mvc.annotation;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -24,6 +25,7 @@ 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;
|
||||
@@ -101,7 +103,7 @@ public class ResponseStatusExceptionResolver extends AbstractHandlerExceptionRes
|
||||
* @return an empty ModelAndView, i.e. exception resolved
|
||||
*/
|
||||
protected ModelAndView resolveResponseStatus(ResponseStatus responseStatus, HttpServletRequest request,
|
||||
HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
HttpServletResponse response, @Nullable Object handler, Exception ex) throws Exception {
|
||||
|
||||
int statusCode = responseStatus.code().value();
|
||||
String reason = responseStatus.reason();
|
||||
@@ -121,7 +123,7 @@ public class ResponseStatusExceptionResolver extends AbstractHandlerExceptionRes
|
||||
* @since 5.0
|
||||
*/
|
||||
protected ModelAndView resolveResponseStatusException(ResponseStatusException ex,
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws Exception {
|
||||
|
||||
int statusCode = ex.getStatus().value();
|
||||
String reason = ex.getReason();
|
||||
@@ -139,7 +141,7 @@ public class ResponseStatusExceptionResolver extends AbstractHandlerExceptionRes
|
||||
* @param response current HTTP response
|
||||
* @since 5.0
|
||||
*/
|
||||
protected ModelAndView applyStatusAndReason(int statusCode, String reason, HttpServletResponse response)
|
||||
protected ModelAndView applyStatusAndReason(int statusCode, @Nullable String reason, HttpServletResponse response)
|
||||
throws IOException {
|
||||
|
||||
if (!StringUtils.hasLength(reason)) {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Support package for annotation-based Servlet MVC controllers.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.servlet.mvc.annotation;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -20,8 +20,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -49,7 +51,7 @@ public class CompositeRequestCondition extends AbstractRequestCondition<Composit
|
||||
* same number of conditions so they may be compared and combined.
|
||||
* It is acceptable to provide {@code null} conditions.
|
||||
*/
|
||||
public CompositeRequestCondition(RequestCondition<?>... requestConditions) {
|
||||
public CompositeRequestCondition(@Nullable RequestCondition<?>... requestConditions) {
|
||||
this.requestConditions = wrap(requestConditions);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.http.InvalidMediaTypeException;
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.web.servlet.mvc.condition;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Contract for request mapping conditions.
|
||||
*
|
||||
@@ -55,6 +57,7 @@ public interface RequestCondition<T> {
|
||||
* empty content thus not causing a failure to match.
|
||||
* @return a condition instance in case of a match or {@code null} otherwise.
|
||||
*/
|
||||
@Nullable
|
||||
T getMatchingCondition(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,8 +18,11 @@ package org.springframework.web.servlet.mvc.condition;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A holder for a {@link RequestCondition} useful when the type of the request
|
||||
* condition is not known ahead of time, e.g. custom condition. Since this
|
||||
@@ -44,7 +47,7 @@ public final class RequestConditionHolder extends AbstractRequestCondition<Reque
|
||||
* @param requestCondition the condition to hold, may be {@code null}
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public RequestConditionHolder(RequestCondition<?> requestCondition) {
|
||||
public RequestConditionHolder(@Nullable RequestCondition<?> requestCondition) {
|
||||
this.condition = (RequestCondition<Object>) requestCondition;
|
||||
}
|
||||
|
||||
@@ -52,6 +55,7 @@ public final class RequestConditionHolder extends AbstractRequestCondition<Reque
|
||||
/**
|
||||
* Return the held request condition, or {@code null} if not holding one.
|
||||
*/
|
||||
@Nullable
|
||||
public RequestCondition<?> getCondition() {
|
||||
return this.condition;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Common MVC logic for matching incoming requests based on conditions.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.servlet.mvc.condition;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -20,6 +20,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerAdapter;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
@@ -95,6 +96,7 @@ public abstract class AbstractHandlerMethodAdapter extends WebContentGenerator i
|
||||
* or {@code null} if the request has been handled directly
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract ModelAndView handleInternal(HttpServletRequest request,
|
||||
HttpServletResponse response, HandlerMethod handlerMethod) throws Exception;
|
||||
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
package org.springframework.web.servlet.mvc.method;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.PathMatcher;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.accept.ContentNegotiationManager;
|
||||
@@ -105,6 +107,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
/**
|
||||
* Return the name for this mapping, or {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
@@ -160,6 +163,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
/**
|
||||
* Returns the "custom" condition of this {@link RequestMappingInfo}; or {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
public RequestCondition<?> getCustomCondition() {
|
||||
return this.customConditionHolder.getCondition();
|
||||
}
|
||||
@@ -532,6 +536,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
/**
|
||||
* Return a custom UrlPathHelper to use for the PatternsRequestCondition, if any.
|
||||
*/
|
||||
|
||||
public UrlPathHelper getUrlPathHelper() {
|
||||
return this.urlPathHelper;
|
||||
}
|
||||
@@ -547,6 +552,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
/**
|
||||
* Return a custom PathMatcher to use for the PatternsRequestCondition, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public PathMatcher getPathMatcher() {
|
||||
return this.pathMatcher;
|
||||
}
|
||||
@@ -626,6 +632,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
* Return the ContentNegotiationManager to use for the ProducesRequestCondition,
|
||||
* if any.
|
||||
*/
|
||||
@Nullable
|
||||
public ContentNegotiationManager getContentNegotiationManager() {
|
||||
return this.contentNegotiationManager;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -47,6 +48,7 @@ import org.springframework.http.converter.GenericHttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -137,7 +139,7 @@ public abstract class AbstractMessageConverterMethodArgumentResolver implements
|
||||
* @throws IOException if the reading from the request fails
|
||||
* @throws HttpMediaTypeNotSupportedException if no suitable message converter is found
|
||||
*/
|
||||
protected <T> Object readWithMessageConverters(NativeWebRequest webRequest, MethodParameter parameter,
|
||||
protected <T> Object readWithMessageConverters(NativeWebRequest webRequest, @Nullable MethodParameter parameter,
|
||||
Type paramType) throws IOException, HttpMediaTypeNotSupportedException, HttpMessageNotReadableException {
|
||||
|
||||
HttpInputMessage inputMessage = createInputMessage(webRequest);
|
||||
@@ -157,7 +159,8 @@ public abstract class AbstractMessageConverterMethodArgumentResolver implements
|
||||
* @throws HttpMediaTypeNotSupportedException if no suitable message converter is found
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> Object readWithMessageConverters(HttpInputMessage inputMessage, MethodParameter parameter,
|
||||
@Nullable
|
||||
protected <T> Object readWithMessageConverters(HttpInputMessage inputMessage, @Nullable MethodParameter parameter,
|
||||
Type targetType) throws IOException, HttpMediaTypeNotSupportedException, HttpMessageNotReadableException {
|
||||
|
||||
MediaType contentType;
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -37,6 +38,7 @@ import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter;
|
||||
import org.springframework.http.converter.xml.SourceHttpMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.accept.ContentNegotiationManager;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
@@ -121,6 +123,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
||||
/**
|
||||
* Return the custom argument resolvers, or {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
public List<HandlerMethodArgumentResolver> getCustomArgumentResolvers() {
|
||||
return this.customArgumentResolvers;
|
||||
}
|
||||
@@ -143,6 +146,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
||||
* Return the configured argument resolvers, or possibly {@code null} if
|
||||
* not initialized yet via {@link #afterPropertiesSet()}.
|
||||
*/
|
||||
@Nullable
|
||||
public HandlerMethodArgumentResolverComposite getArgumentResolvers() {
|
||||
return this.argumentResolvers;
|
||||
}
|
||||
@@ -159,6 +163,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
||||
/**
|
||||
* Return the custom return value handlers, or {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
public List<HandlerMethodReturnValueHandler> getCustomReturnValueHandlers() {
|
||||
return this.customReturnValueHandlers;
|
||||
}
|
||||
@@ -181,6 +186,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
||||
* Return the configured handlers, or possibly {@code null} if not
|
||||
* initialized yet via {@link #afterPropertiesSet()}.
|
||||
*/
|
||||
@Nullable
|
||||
public HandlerMethodReturnValueHandlerComposite getReturnValueHandlers() {
|
||||
return this.returnValueHandlers;
|
||||
}
|
||||
@@ -423,7 +429,8 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
||||
* @param exception the raised exception
|
||||
* @return a method to handle the exception, or {@code null}
|
||||
*/
|
||||
protected ServletInvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handlerMethod, Exception exception) {
|
||||
@Nullable
|
||||
protected ServletInvocableHandlerMethod getExceptionHandlerMethod(@Nullable HandlerMethod handlerMethod, Exception exception) {
|
||||
Class<?> handlerType = (handlerMethod != null ? handlerMethod.getBeanType() : null);
|
||||
|
||||
if (handlerMethod != null) {
|
||||
|
||||
@@ -18,9 +18,11 @@ package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.bind.ServletRequestDataBinder;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
|
||||
@@ -39,7 +41,7 @@ public class ExtendedServletRequestDataBinder extends ServletRequestDataBinder {
|
||||
* if the binder is just used to convert a plain parameter value)
|
||||
* @see #DEFAULT_OBJECT_NAME
|
||||
*/
|
||||
public ExtendedServletRequestDataBinder(Object target) {
|
||||
public ExtendedServletRequestDataBinder(@Nullable Object target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@@ -50,7 +52,7 @@ public class ExtendedServletRequestDataBinder extends ServletRequestDataBinder {
|
||||
* @param objectName the name of the target object
|
||||
* @see #DEFAULT_OBJECT_NAME
|
||||
*/
|
||||
public ExtendedServletRequestDataBinder(Object target, String objectName) {
|
||||
public ExtendedServletRequestDataBinder(@Nullable Object target, String objectName) {
|
||||
super(target, objectName);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.http.server.ServletServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -142,6 +143,7 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Type getHttpEntityType(MethodParameter parameter) {
|
||||
Assert.isAssignable(HttpEntity.class, parameter.getParameterType());
|
||||
Type parameterType = parameter.getGenericParameterType();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.PatternMatchUtils;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||
@@ -62,6 +63,7 @@ public class ModelAndViewMethodReturnValueHandler implements HandlerMethodReturn
|
||||
/**
|
||||
* The configured redirect patterns, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public String[] getRedirectPatterns() {
|
||||
return this.redirectPatterns;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.annotation.SynthesizingMethodParameter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.objenesis.ObjenesisException;
|
||||
import org.springframework.objenesis.SpringObjenesis;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
@@ -489,6 +490,7 @@ public class MvcUriComponentsBuilder {
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static CompositeUriComponentsContributor getConfiguredUriComponentsContributor() {
|
||||
WebApplicationContext wac = getWebApplicationContext();
|
||||
if (wac == null) {
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.ServerSentEvent;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MimeType;
|
||||
@@ -107,6 +108,7 @@ class ReactiveTypeHandler {
|
||||
* @return an emitter for streaming or {@code null} if handled internally
|
||||
* with a {@link DeferredResult}.
|
||||
*/
|
||||
@Nullable
|
||||
public ResponseBodyEmitter handleValue(Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mav, NativeWebRequest request) throws Exception {
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.lang.reflect.Type;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.http.HttpInputMessage;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Allows customizing the request before its body is read and converted into an
|
||||
@@ -60,7 +61,8 @@ public interface RequestBodyAdvice {
|
||||
* @return the value to use or {@code null} which may then raise an
|
||||
* {@code HttpMessageNotReadableException} if the argument is required.
|
||||
*/
|
||||
Object handleEmptyBody(Object body, HttpInputMessage inputMessage, MethodParameter parameter,
|
||||
@Nullable
|
||||
Object handleEmptyBody(@Nullable Object body, HttpInputMessage inputMessage, MethodParameter parameter,
|
||||
Type targetType, Class<? extends HttpMessageConverter<?>> converterType);
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
@@ -46,6 +47,7 @@ import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter;
|
||||
import org.springframework.http.converter.xml.SourceHttpMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -197,6 +199,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
/**
|
||||
* Return the custom argument resolvers, or {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
public List<HandlerMethodArgumentResolver> getCustomArgumentResolvers() {
|
||||
return this.customArgumentResolvers;
|
||||
}
|
||||
@@ -219,6 +222,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
* Return the configured argument resolvers, or possibly {@code null} if
|
||||
* not initialized yet via {@link #afterPropertiesSet()}.
|
||||
*/
|
||||
@Nullable
|
||||
public List<HandlerMethodArgumentResolver> getArgumentResolvers() {
|
||||
return (this.argumentResolvers != null) ? this.argumentResolvers.getResolvers() : null;
|
||||
}
|
||||
@@ -240,6 +244,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
* Return the argument resolvers for {@code @InitBinder} methods, or possibly
|
||||
* {@code null} if not initialized yet via {@link #afterPropertiesSet()}.
|
||||
*/
|
||||
@Nullable
|
||||
public List<HandlerMethodArgumentResolver> getInitBinderArgumentResolvers() {
|
||||
return (this.initBinderArgumentResolvers != null) ? this.initBinderArgumentResolvers.getResolvers() : null;
|
||||
}
|
||||
@@ -256,6 +261,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
/**
|
||||
* Return the custom return value handlers, or {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
public List<HandlerMethodReturnValueHandler> getCustomReturnValueHandlers() {
|
||||
return this.customReturnValueHandlers;
|
||||
}
|
||||
@@ -278,6 +284,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
* Return the configured handlers, or possibly {@code null} if not
|
||||
* initialized yet via {@link #afterPropertiesSet()}.
|
||||
*/
|
||||
@Nullable
|
||||
public List<HandlerMethodReturnValueHandler> getReturnValueHandlers() {
|
||||
return this.returnValueHandlers.getHandlers();
|
||||
}
|
||||
@@ -303,6 +310,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
/**
|
||||
* Return the configured {@link ModelAndViewResolver}s, or {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
public List<ModelAndViewResolver> getModelAndViewResolvers() {
|
||||
return modelAndViewResolvers;
|
||||
}
|
||||
@@ -364,6 +372,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
/**
|
||||
* Return the configured WebBindingInitializer, or {@code null} if none.
|
||||
*/
|
||||
@Nullable
|
||||
public WebBindingInitializer getWebBindingInitializer() {
|
||||
return this.webBindingInitializer;
|
||||
}
|
||||
@@ -520,6 +529,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
/**
|
||||
* Return the owning factory of this bean instance, or {@code null} if none.
|
||||
*/
|
||||
@Nullable
|
||||
protected ConfigurableBeanFactory getBeanFactory() {
|
||||
return this.beanFactory;
|
||||
}
|
||||
@@ -805,6 +815,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
* @since 4.2
|
||||
* @see #createInvocableHandlerMethod(HandlerMethod)
|
||||
*/
|
||||
@Nullable
|
||||
protected ModelAndView invokeHandlerMethod(HttpServletRequest request,
|
||||
HttpServletResponse response, HandlerMethod handlerMethod) throws Exception {
|
||||
|
||||
@@ -944,6 +955,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
return new ServletRequestDataBinderFactory(binderMethods, getWebBindingInitializer());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ModelAndView getModelAndView(ModelAndViewContainer mavContainer,
|
||||
ModelFactory modelFactory, NativeWebRequest webRequest) throws Exception {
|
||||
|
||||
|
||||
@@ -20,10 +20,12 @@ import java.lang.reflect.AnnotatedElement;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.context.EmbeddedValueResolverAware;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -219,6 +221,7 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
|
||||
* @param handlerType the handler type for which to create the condition
|
||||
* @return the condition, or {@code null}
|
||||
*/
|
||||
@Nullable
|
||||
protected RequestCondition<?> getCustomTypeCondition(Class<?> handlerType) {
|
||||
return null;
|
||||
}
|
||||
@@ -234,6 +237,7 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
|
||||
* @param method the handler method for which to create the condition
|
||||
* @return the condition, or {@code null}
|
||||
*/
|
||||
@Nullable
|
||||
protected RequestCondition<?> getCustomMethodCondition(Method method) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Set;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -98,6 +99,7 @@ public class ResponseBodyEmitter {
|
||||
/**
|
||||
* Return the configured timeout value, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public Long getTimeout() {
|
||||
return this.timeout;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.http.converter.HttpMessageNotWritableException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
||||
@@ -446,6 +447,7 @@ public abstract class ResponseEntityExceptionHandler {
|
||||
* @return a {@code ResponseEntity} instance
|
||||
* @since 4.2.8
|
||||
*/
|
||||
@Nullable
|
||||
protected ResponseEntity<Object> handleAsyncRequestTimeoutException(
|
||||
AsyncRequestTimeoutException ex, HttpHeaders headers, HttpStatus status, WebRequest webRequest) {
|
||||
|
||||
|
||||
@@ -18,12 +18,14 @@ package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.DataBinder;
|
||||
import org.springframework.web.bind.ServletRequestDataBinder;
|
||||
@@ -90,6 +92,7 @@ public class ServletModelAttributeMethodProcessor extends ModelAttributeMethodPr
|
||||
* @param request the current request
|
||||
* @return the request value to try to convert, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
protected String getRequestValueForAttribute(String attributeName, NativeWebRequest request) {
|
||||
Map<String, String> variables = getUriTemplateVariables(request);
|
||||
String variableValue = variables.get(attributeName);
|
||||
@@ -124,7 +127,8 @@ public class ServletModelAttributeMethodProcessor extends ModelAttributeMethodPr
|
||||
* conversion found
|
||||
* @throws Exception
|
||||
*/
|
||||
protected Object createAttributeFromRequestValue(String sourceValue, String attributeName,
|
||||
@Nullable
|
||||
protected Object createAttributeFromRequestValue(String sourceValue, @Nullable String attributeName,
|
||||
MethodParameter methodParam, WebDataBinderFactory binderFactory, NativeWebRequest request)
|
||||
throws Exception {
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.PatternMatchUtils;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||
@@ -62,6 +63,7 @@ public class ViewNameMethodReturnValueHandler implements HandlerMethodReturnValu
|
||||
/**
|
||||
* The configured redirect patterns, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public String[] getRedirectPatterns() {
|
||||
return this.redirectPatterns;
|
||||
}
|
||||
|
||||
@@ -4,4 +4,7 @@
|
||||
* {@link org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping}
|
||||
* and {@link org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter}.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* Servlet-based infrastructure for handler method processing,
|
||||
* building on the {@code org.springframework.web.method} package.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.servlet.mvc.method;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* Standard controller implementations for the Servlet MVC framework that comes with
|
||||
* Spring. Provides various controller styles, including an annotation-based model.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.servlet.mvc;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.web.servlet.mvc.support;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -30,6 +31,7 @@ import org.springframework.core.Ordered;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.http.converter.HttpMessageNotWritableException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.BindException;
|
||||
@@ -181,7 +183,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
|
||||
* @throws IOException potentially thrown from response.sendError()
|
||||
*/
|
||||
protected ModelAndView handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex,
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
|
||||
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
|
||||
|
||||
pageNotFoundLogger.warn(ex.getMessage());
|
||||
String[] supportedMethods = ex.getSupportedMethods();
|
||||
@@ -448,7 +450,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
|
||||
* @since 4.0
|
||||
*/
|
||||
protected ModelAndView handleNoHandlerFoundException(NoHandlerFoundException ex,
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
|
||||
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
|
||||
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
return new ModelAndView();
|
||||
@@ -467,7 +469,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
|
||||
* @since 4.2.8
|
||||
*/
|
||||
protected ModelAndView handleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex,
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
|
||||
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
|
||||
|
||||
if (!response.isCommitted()) {
|
||||
response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.servlet.mvc.support;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.servlet.FlashMap;
|
||||
|
||||
@@ -76,7 +77,7 @@ public interface RedirectAttributes extends Model {
|
||||
* @param attributeName the attribute name; never {@code null}
|
||||
* @param attributeValue the attribute value; may be {@code null}
|
||||
*/
|
||||
RedirectAttributes addFlashAttribute(String attributeName, Object attributeValue);
|
||||
RedirectAttributes addFlashAttribute(String attributeName, @Nullable Object attributeValue);
|
||||
|
||||
/**
|
||||
* Add the given flash storage using a
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* Support package for MVC controllers.
|
||||
* Contains a special HandlerMapping for controller conventions.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.servlet.mvc.support;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -7,4 +7,7 @@
|
||||
* <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/">Expert One-On-One J2EE Design and Development</a>
|
||||
* by Rod Johnson (Wrox, 2002).
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.servlet;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Base class for {@link org.springframework.web.servlet.resource.ResourceResolver}
|
||||
@@ -58,6 +59,7 @@ public abstract class AbstractResourceResolver implements ResourceResolver {
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
protected abstract Resource resolveResourceInternal(HttpServletRequest request, String requestPath,
|
||||
List<? extends Resource> locations, ResourceResolverChain chain);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -71,6 +72,7 @@ class DefaultResourceTransformerChain implements ResourceTransformerChain {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ResourceTransformer getNext() {
|
||||
Assert.state(this.index <= this.transformers.size(),
|
||||
"Current index exceeds the number of configured ResourceTransformer's");
|
||||
|
||||
@@ -20,11 +20,13 @@ import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.support.ServletContextResource;
|
||||
|
||||
@@ -85,6 +87,7 @@ public class PathResourceResolver extends AbstractResourceResolver {
|
||||
return (StringUtils.hasText(resourcePath) && getResource(resourcePath, locations) != null ? resourcePath : null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Resource getResource(String resourcePath, List<? extends Resource> locations) {
|
||||
for (Resource location : locations) {
|
||||
try {
|
||||
@@ -117,6 +120,7 @@ public class PathResourceResolver extends AbstractResourceResolver {
|
||||
* @param location the location to check
|
||||
* @return the resource, or {@code null} if none found
|
||||
*/
|
||||
@Nullable
|
||||
protected Resource getResource(String resourcePath, Resource location) throws IOException {
|
||||
Resource resource = location.createRelative(resourcePath);
|
||||
if (resource.exists() && resource.isReadable()) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -40,6 +41,7 @@ import org.springframework.http.converter.ResourceHttpMessageConverter;
|
||||
import org.springframework.http.converter.ResourceRegionHttpMessageConverter;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.http.server.ServletServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -391,6 +393,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Resource getResource(HttpServletRequest request) throws IOException {
|
||||
String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
|
||||
if (path == null) {
|
||||
@@ -511,6 +514,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
|
||||
* @param resource the resource to check
|
||||
* @return the corresponding media type, or {@code null} if none found
|
||||
*/
|
||||
@Nullable
|
||||
protected MediaType getMediaType(HttpServletRequest request, Resource resource) {
|
||||
return this.contentNegotiationStrategy.getMediaTypeForResource(resource);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
package org.springframework.web.servlet.resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A strategy for resolving a request to a server-side resource.
|
||||
@@ -45,6 +47,7 @@ public interface ResourceResolver {
|
||||
* @param chain the chain of remaining resolvers to delegate to
|
||||
* @return the resolved resource or {@code null} if unresolved
|
||||
*/
|
||||
@Nullable
|
||||
Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations,
|
||||
ResourceResolverChain chain);
|
||||
|
||||
@@ -58,6 +61,7 @@ public interface ResourceResolver {
|
||||
* @param chain the chain of resolvers to delegate to
|
||||
* @return the resolved public URL path or {@code null} if unresolved
|
||||
*/
|
||||
@Nullable
|
||||
String resolveUrlPath(String resourcePath, List<? extends Resource> locations, ResourceResolverChain chain);
|
||||
|
||||
}
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
package org.springframework.web.servlet.resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A contract for invoking a chain of {@link ResourceResolver}s where each resolver
|
||||
@@ -40,6 +42,7 @@ public interface ResourceResolverChain {
|
||||
* @param locations the locations to search in when looking up resources
|
||||
* @return the resolved resource or {@code null} if unresolved
|
||||
*/
|
||||
@Nullable
|
||||
Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations);
|
||||
|
||||
/**
|
||||
@@ -51,6 +54,7 @@ public interface ResourceResolverChain {
|
||||
* @param locations the locations to search in when looking up resources
|
||||
* @return the resolved public URL path or {@code null} if unresolved
|
||||
*/
|
||||
@Nullable
|
||||
String resolveUrlPath(String resourcePath, List<? extends Resource> locations);
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Collections;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -65,6 +66,7 @@ public abstract class ResourceTransformerSupport implements ResourceTransformer
|
||||
* @param transformerChain the transformer chain
|
||||
* @return the resolved URL or null
|
||||
*/
|
||||
@Nullable
|
||||
protected String resolveUrlPath(String resourcePath, HttpServletRequest request,
|
||||
Resource resource, ResourceTransformerChain transformerChain) {
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.PathMatcher;
|
||||
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
||||
@@ -169,6 +170,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
|
||||
* @param requestUrl the request URL path to resolve
|
||||
* @return the resolved public URL path, or {@code null} if unresolved
|
||||
*/
|
||||
@Nullable
|
||||
public final String getForRequestUrl(HttpServletRequest request, String requestUrl) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Getting resource URL for request URL \"" + requestUrl + "\"");
|
||||
@@ -214,6 +216,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
|
||||
* @param lookupPath the lookup path to check
|
||||
* @return the resolved public URL path, or {@code null} if unresolved
|
||||
*/
|
||||
@Nullable
|
||||
public final String getForLookupPath(String lookupPath) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Getting resource URL for lookup path \"" + lookupPath + "\"");
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.web.servlet.resource;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A strategy for extracting and embedding a resource version in its URL path.
|
||||
*
|
||||
@@ -30,6 +32,7 @@ public interface VersionPathStrategy {
|
||||
* @param requestPath the request path to check
|
||||
* @return the version string or {@code null} if none was found
|
||||
*/
|
||||
@Nullable
|
||||
String extractVersion(String requestPath);
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import org.springframework.core.io.AbstractResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -225,6 +226,7 @@ public class VersionResourceResolver extends AbstractResourceResolver {
|
||||
* Find a {@code VersionStrategy} for the request path of the requested resource.
|
||||
* @return an instance of a {@code VersionStrategy} or null if none matches that request path
|
||||
*/
|
||||
@Nullable
|
||||
protected VersionStrategy getStrategyForPath(String requestPath) {
|
||||
String path = "/".concat(requestPath);
|
||||
List<String> matchingPatterns = new ArrayList<>();
|
||||
|
||||
@@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import org.webjars.WebJarAssetLocator;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A {@code ResourceResolver} that delegates to the chain to locate a resource and then
|
||||
@@ -98,6 +99,7 @@ public class WebJarsResourceResolver extends AbstractResourceResolver {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String findWebJarResourcePath(String path) {
|
||||
int startOffset = (path.startsWith("/") ? 1 : 0);
|
||||
int endOffset = path.indexOf("/", 1);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Support classes for serving static resources.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.servlet.resource;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.web.servlet.support;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||
@@ -49,6 +50,7 @@ public abstract class AbstractAnnotationConfigDispatcherServletInitializer
|
||||
* Returns {@code null} if {@link #getRootConfigClasses()} returns {@code null}.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
protected WebApplicationContext createRootApplicationContext() {
|
||||
Class<?>[] configClasses = getRootConfigClasses();
|
||||
if (!ObjectUtils.isEmpty(configClasses)) {
|
||||
@@ -83,6 +85,7 @@ public abstract class AbstractAnnotationConfigDispatcherServletInitializer
|
||||
* @return the configuration classes for the root application context, or {@code null}
|
||||
* if creation and registration of a root context is not desired
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract Class<?>[] getRootConfigClasses();
|
||||
|
||||
/**
|
||||
@@ -93,6 +96,7 @@ public abstract class AbstractAnnotationConfigDispatcherServletInitializer
|
||||
* @return the configuration classes for the dispatcher servlet application context or
|
||||
* {@code null} if all configuration is specified through root config classes.
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract Class<?>[] getServletConfigClasses();
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.web.servlet.support;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterRegistration;
|
||||
@@ -27,6 +28,7 @@ import javax.servlet.ServletRegistration;
|
||||
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.core.Conventions;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.context.AbstractContextLoaderInitializer;
|
||||
@@ -150,6 +152,7 @@ public abstract class AbstractDispatcherServletInitializer extends AbstractConte
|
||||
* @see DispatcherServlet#setContextInitializers
|
||||
* @see #getRootApplicationContextInitializers()
|
||||
*/
|
||||
@Nullable
|
||||
protected ApplicationContextInitializer<?>[] getServletApplicationContextInitializers() {
|
||||
return null;
|
||||
}
|
||||
@@ -166,6 +169,7 @@ public abstract class AbstractDispatcherServletInitializer extends AbstractConte
|
||||
* @return an array of filters or {@code null}
|
||||
* @see #registerServletFilter(ServletContext, Filter)
|
||||
*/
|
||||
@Nullable
|
||||
protected Filter[] getServletFilters() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -143,6 +144,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
|
||||
* Return a FlashMap contained in the given list that matches the request.
|
||||
* @return a matching FlashMap or {@code null}
|
||||
*/
|
||||
@Nullable
|
||||
private FlashMap getMatchingFlashMap(List<FlashMap> allMaps, HttpServletRequest request) {
|
||||
List<FlashMap> result = new LinkedList<>();
|
||||
for (FlashMap flashMap : allMaps) {
|
||||
@@ -241,6 +243,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
|
||||
* @param request the current request
|
||||
* @return a List with FlashMap instances, or {@code null} if none found
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract List<FlashMap> retrieveFlashMaps(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
@@ -262,6 +265,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
|
||||
* @return the mutex to use (may be {@code null} if none applicable)
|
||||
* @since 4.0.3
|
||||
*/
|
||||
@Nullable
|
||||
protected Object getFlashMapsMutex(HttpServletRequest request) {
|
||||
return DEFAULT_FLASH_MAPS_MUTEX;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
import org.springframework.beans.BeanWrapper;
|
||||
import org.springframework.beans.PropertyAccessorFactory;
|
||||
import org.springframework.context.NoSuchMessageException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.Errors;
|
||||
@@ -199,6 +200,7 @@ public class BindStatus {
|
||||
* Note that the complete bind path as required by the bind tag is
|
||||
* "customer.address.street", if bound to a "customer" bean.
|
||||
*/
|
||||
@Nullable
|
||||
public String getExpression() {
|
||||
return this.expression;
|
||||
}
|
||||
@@ -209,6 +211,7 @@ public class BindStatus {
|
||||
* <p>This value will be an HTML-escaped String if the original value
|
||||
* already was a String.
|
||||
*/
|
||||
@Nullable
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
@@ -218,6 +221,7 @@ public class BindStatus {
|
||||
* '{@code getValue().getClass()}' since '{@code getValue()}' may
|
||||
* return '{@code null}'.
|
||||
*/
|
||||
@Nullable
|
||||
public Class<?> getValueType() {
|
||||
return this.valueType;
|
||||
}
|
||||
@@ -226,6 +230,7 @@ public class BindStatus {
|
||||
* Return the actual value of the field, i.e. the raw property value,
|
||||
* or {@code null} if not available.
|
||||
*/
|
||||
@Nullable
|
||||
public Object getActualValue() {
|
||||
return this.actualValue;
|
||||
}
|
||||
@@ -258,6 +263,7 @@ public class BindStatus {
|
||||
* Return the error codes for the field or object, if any.
|
||||
* Returns an empty array instead of null if none.
|
||||
*/
|
||||
@Nullable
|
||||
public String[] getErrorCodes() {
|
||||
return this.errorCodes;
|
||||
}
|
||||
@@ -303,6 +309,7 @@ public class BindStatus {
|
||||
* @return the current Errors instance, or {@code null} if none
|
||||
* @see org.springframework.validation.BindingResult
|
||||
*/
|
||||
@Nullable
|
||||
public Errors getErrors() {
|
||||
return this.errors;
|
||||
}
|
||||
@@ -312,6 +319,7 @@ public class BindStatus {
|
||||
* is currently bound to.
|
||||
* @return the current PropertyEditor, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
public PropertyEditor getEditor() {
|
||||
return this.editor;
|
||||
}
|
||||
@@ -322,6 +330,7 @@ public class BindStatus {
|
||||
* @param valueClass the value class that an editor is needed for
|
||||
* @return the associated PropertyEditor, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
public PropertyEditor findEditor(Class<?> valueClass) {
|
||||
return (this.bindingResult != null ? this.bindingResult.findEditor(this.expression, valueClass) : null);
|
||||
}
|
||||
|
||||
@@ -18,11 +18,14 @@ package org.springframework.web.servlet.support;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.jstl.core.Config;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* JSP-aware (and JSTL-aware) subclass of RequestContext, allowing for
|
||||
* population of the context from a {@code javax.servlet.jsp.PageContext}.
|
||||
@@ -55,7 +58,7 @@ public class JspAwareRequestContext extends RequestContext {
|
||||
* @param model the model attributes for the current view
|
||||
* (can be {@code null}, using the request attributes for Errors retrieval)
|
||||
*/
|
||||
public JspAwareRequestContext(PageContext pageContext, Map<String, Object> model) {
|
||||
public JspAwareRequestContext(PageContext pageContext, @Nullable Map<String, Object> model) {
|
||||
initContext(pageContext, model);
|
||||
}
|
||||
|
||||
@@ -66,7 +69,7 @@ public class JspAwareRequestContext extends RequestContext {
|
||||
* @param model the model attributes for the current view
|
||||
* (can be {@code null}, using the request attributes for Errors retrieval)
|
||||
*/
|
||||
protected void initContext(PageContext pageContext, Map<String, Object> model) {
|
||||
protected void initContext(PageContext pageContext, @Nullable Map<String, Object> model) {
|
||||
if (!(pageContext.getRequest() instanceof HttpServletRequest)) {
|
||||
throw new IllegalArgumentException("RequestContext only supports HTTP requests");
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.servlet.support;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
@@ -28,6 +29,7 @@ import javax.servlet.jsp.jstl.fmt.LocalizationContext;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.support.MessageSourceResourceBundle;
|
||||
import org.springframework.context.support.ResourceBundleMessageSource;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Helper class for preparing JSTL views,
|
||||
@@ -77,7 +79,7 @@ public abstract class JstlUtils {
|
||||
* typically the current ApplicationContext (may be {@code null})
|
||||
* @see #exposeLocalizationContext(RequestContext)
|
||||
*/
|
||||
public static void exposeLocalizationContext(HttpServletRequest request, MessageSource messageSource) {
|
||||
public static void exposeLocalizationContext(HttpServletRequest request, @Nullable MessageSource messageSource) {
|
||||
Locale jstlLocale = RequestContextUtils.getLocale(request);
|
||||
Config.set(request, Config.FMT_LOCALE, jstlLocale);
|
||||
TimeZone timeZone = RequestContextUtils.getTimeZone(request);
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -33,6 +34,7 @@ import org.springframework.context.NoSuchMessageException;
|
||||
import org.springframework.context.i18n.LocaleContext;
|
||||
import org.springframework.context.i18n.SimpleTimeZoneAwareLocaleContext;
|
||||
import org.springframework.context.i18n.TimeZoneAwareLocaleContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.ui.context.Theme;
|
||||
import org.springframework.ui.context.ThemeSource;
|
||||
import org.springframework.ui.context.support.ResourceBundleThemeSource;
|
||||
@@ -160,7 +162,7 @@ public class RequestContext {
|
||||
* @see org.springframework.web.context.WebApplicationContext
|
||||
* @see org.springframework.web.servlet.DispatcherServlet
|
||||
*/
|
||||
public RequestContext(HttpServletRequest request, ServletContext servletContext) {
|
||||
public RequestContext(HttpServletRequest request, @Nullable ServletContext servletContext) {
|
||||
initContext(request, null, servletContext, null);
|
||||
}
|
||||
|
||||
@@ -175,7 +177,7 @@ public class RequestContext {
|
||||
* @see org.springframework.web.servlet.DispatcherServlet
|
||||
* @see #RequestContext(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.ServletContext, Map)
|
||||
*/
|
||||
public RequestContext(HttpServletRequest request, Map<String, Object> model) {
|
||||
public RequestContext(HttpServletRequest request, @Nullable Map<String, Object> model) {
|
||||
initContext(request, null, null, model);
|
||||
}
|
||||
|
||||
@@ -193,8 +195,8 @@ public class RequestContext {
|
||||
* @see org.springframework.web.context.WebApplicationContext
|
||||
* @see org.springframework.web.servlet.DispatcherServlet
|
||||
*/
|
||||
public RequestContext(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext,
|
||||
Map<String, Object> model) {
|
||||
public RequestContext(HttpServletRequest request, HttpServletResponse response, @Nullable ServletContext servletContext,
|
||||
@Nullable Map<String, Object> model) {
|
||||
|
||||
initContext(request, response, servletContext, model);
|
||||
}
|
||||
@@ -220,8 +222,8 @@ public class RequestContext {
|
||||
* @see org.springframework.web.servlet.DispatcherServlet#LOCALE_RESOLVER_ATTRIBUTE
|
||||
* @see org.springframework.web.servlet.DispatcherServlet#THEME_RESOLVER_ATTRIBUTE
|
||||
*/
|
||||
protected void initContext(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext,
|
||||
Map<String, Object> model) {
|
||||
protected void initContext(HttpServletRequest request, HttpServletResponse response, @Nullable ServletContext servletContext,
|
||||
@Nullable Map<String, Object> model) {
|
||||
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
@@ -299,6 +301,7 @@ public class RequestContext {
|
||||
* session or application scope; returns {@code null} if not found.
|
||||
* @return the fallback time zone (or {@code null} if none derivable from the request)
|
||||
*/
|
||||
@Nullable
|
||||
protected TimeZone getFallbackTimeZone() {
|
||||
if (jstlPresent) {
|
||||
TimeZone timeZone = JstlLocaleResolver.getJstlTimeZone(getRequest(), getServletContext());
|
||||
@@ -314,6 +317,7 @@ public class RequestContext {
|
||||
* <p>The default implementation returns the default theme (with name "theme").
|
||||
* @return the fallback theme (never {@code null})
|
||||
*/
|
||||
@Nullable
|
||||
protected Theme getFallbackTheme() {
|
||||
ThemeSource themeSource = RequestContextUtils.getThemeSource(getRequest());
|
||||
if (themeSource == null) {
|
||||
@@ -359,6 +363,7 @@ public class RequestContext {
|
||||
* Return the model Map that this RequestContext encapsulates, if any.
|
||||
* @return the populated model Map, or {@code null} if none available
|
||||
*/
|
||||
@Nullable
|
||||
public final Map<String, Object> getModel() {
|
||||
return this.model;
|
||||
}
|
||||
@@ -379,6 +384,7 @@ public class RequestContext {
|
||||
* Also includes a fallback check for JSTL's TimeZone attribute.
|
||||
* @see RequestContextUtils#getTimeZone
|
||||
*/
|
||||
@Nullable
|
||||
public TimeZone getTimeZone() {
|
||||
return this.timeZone;
|
||||
}
|
||||
@@ -534,6 +540,7 @@ public class RequestContext {
|
||||
* WebApplicationContext under the name {@code "requestDataValueProcessor"}.
|
||||
* Or {@code null} if no matching bean was found.
|
||||
*/
|
||||
@Nullable
|
||||
public RequestDataValueProcessor getRequestDataValueProcessor() {
|
||||
return this.requestDataValueProcessor;
|
||||
}
|
||||
@@ -639,7 +646,7 @@ public class RequestContext {
|
||||
* @param defaultMessage String to return if the lookup fails
|
||||
* @return the message
|
||||
*/
|
||||
public String getMessage(String code, Object[] args, String defaultMessage) {
|
||||
public String getMessage(String code, @Nullable Object[] args, String defaultMessage) {
|
||||
return getMessage(code, args, defaultMessage, isDefaultHtmlEscape());
|
||||
}
|
||||
|
||||
@@ -650,7 +657,7 @@ public class RequestContext {
|
||||
* @param defaultMessage String to return if the lookup fails
|
||||
* @return the message
|
||||
*/
|
||||
public String getMessage(String code, List<?> args, String defaultMessage) {
|
||||
public String getMessage(String code, @Nullable List<?> args, String defaultMessage) {
|
||||
return getMessage(code, (args != null ? args.toArray() : null), defaultMessage, isDefaultHtmlEscape());
|
||||
}
|
||||
|
||||
@@ -662,7 +669,7 @@ public class RequestContext {
|
||||
* @param htmlEscape HTML escape the message?
|
||||
* @return the message
|
||||
*/
|
||||
public String getMessage(String code, Object[] args, String defaultMessage, boolean htmlEscape) {
|
||||
public String getMessage(String code, @Nullable Object[] args, String defaultMessage, boolean htmlEscape) {
|
||||
String msg = this.webApplicationContext.getMessage(code, args, defaultMessage, this.locale);
|
||||
return (htmlEscape ? HtmlUtils.htmlEscape(msg) : msg);
|
||||
}
|
||||
@@ -684,7 +691,7 @@ public class RequestContext {
|
||||
* @return the message
|
||||
* @throws org.springframework.context.NoSuchMessageException if not found
|
||||
*/
|
||||
public String getMessage(String code, Object[] args) throws NoSuchMessageException {
|
||||
public String getMessage(String code, @Nullable Object[] args) throws NoSuchMessageException {
|
||||
return getMessage(code, args, isDefaultHtmlEscape());
|
||||
}
|
||||
|
||||
@@ -695,7 +702,7 @@ public class RequestContext {
|
||||
* @return the message
|
||||
* @throws org.springframework.context.NoSuchMessageException if not found
|
||||
*/
|
||||
public String getMessage(String code, List<?> args) throws NoSuchMessageException {
|
||||
public String getMessage(String code, @Nullable List<?> args) throws NoSuchMessageException {
|
||||
return getMessage(code, (args != null ? args.toArray() : null), isDefaultHtmlEscape());
|
||||
}
|
||||
|
||||
@@ -707,7 +714,7 @@ public class RequestContext {
|
||||
* @return the message
|
||||
* @throws org.springframework.context.NoSuchMessageException if not found
|
||||
*/
|
||||
public String getMessage(String code, Object[] args, boolean htmlEscape) throws NoSuchMessageException {
|
||||
public String getMessage(String code, @Nullable Object[] args, boolean htmlEscape) throws NoSuchMessageException {
|
||||
String msg = this.webApplicationContext.getMessage(code, args, this.locale);
|
||||
return (htmlEscape ? HtmlUtils.htmlEscape(msg) : msg);
|
||||
}
|
||||
@@ -755,7 +762,7 @@ public class RequestContext {
|
||||
* @param defaultMessage String to return if the lookup fails
|
||||
* @return the message
|
||||
*/
|
||||
public String getThemeMessage(String code, Object[] args, String defaultMessage) {
|
||||
public String getThemeMessage(String code, @Nullable Object[] args, String defaultMessage) {
|
||||
return getTheme().getMessageSource().getMessage(code, args, defaultMessage, this.locale);
|
||||
}
|
||||
|
||||
@@ -768,7 +775,7 @@ public class RequestContext {
|
||||
* @param defaultMessage String to return if the lookup fails
|
||||
* @return the message
|
||||
*/
|
||||
public String getThemeMessage(String code, List<?> args, String defaultMessage) {
|
||||
public String getThemeMessage(String code, @Nullable List<?> args, String defaultMessage) {
|
||||
return getTheme().getMessageSource().getMessage(code, (args != null ? args.toArray() : null), defaultMessage,
|
||||
this.locale);
|
||||
}
|
||||
@@ -794,7 +801,7 @@ public class RequestContext {
|
||||
* @return the message
|
||||
* @throws org.springframework.context.NoSuchMessageException if not found
|
||||
*/
|
||||
public String getThemeMessage(String code, Object[] args) throws NoSuchMessageException {
|
||||
public String getThemeMessage(String code, @Nullable Object[] args) throws NoSuchMessageException {
|
||||
return getTheme().getMessageSource().getMessage(code, args, this.locale);
|
||||
}
|
||||
|
||||
@@ -807,7 +814,7 @@ public class RequestContext {
|
||||
* @return the message
|
||||
* @throws org.springframework.context.NoSuchMessageException if not found
|
||||
*/
|
||||
public String getThemeMessage(String code, List<?> args) throws NoSuchMessageException {
|
||||
public String getThemeMessage(String code, @Nullable List<?> args) throws NoSuchMessageException {
|
||||
return getTheme().getMessageSource().getMessage(code, (args != null ? args.toArray() : null), this.locale);
|
||||
}
|
||||
|
||||
@@ -828,6 +835,7 @@ public class RequestContext {
|
||||
* @param name name of the bind object
|
||||
* @return the Errors instance, or {@code null} if not found
|
||||
*/
|
||||
@Nullable
|
||||
public Errors getErrors(String name) {
|
||||
return getErrors(name, isDefaultHtmlEscape());
|
||||
}
|
||||
@@ -838,6 +846,7 @@ public class RequestContext {
|
||||
* @param htmlEscape create an Errors instance with automatic HTML escaping?
|
||||
* @return the Errors instance, or {@code null} if not found
|
||||
*/
|
||||
@Nullable
|
||||
public Errors getErrors(String name, boolean htmlEscape) {
|
||||
if (this.errorsMap == null) {
|
||||
this.errorsMap = new HashMap<>();
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.servlet.support;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -26,6 +27,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.context.i18n.LocaleContext;
|
||||
import org.springframework.context.i18n.TimeZoneAwareLocaleContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.ui.context.Theme;
|
||||
import org.springframework.ui.context.ThemeSource;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -81,6 +83,7 @@ public abstract class RequestContextUtils {
|
||||
* @see WebApplicationContextUtils#getWebApplicationContext(ServletContext)
|
||||
* @see ContextLoader#getCurrentWebApplicationContext()
|
||||
*/
|
||||
@Nullable
|
||||
public static WebApplicationContext findWebApplicationContext(
|
||||
HttpServletRequest request, ServletContext servletContext) {
|
||||
|
||||
@@ -112,6 +115,7 @@ public abstract class RequestContextUtils {
|
||||
* @see ServletRequest#getServletContext()
|
||||
* @see ContextLoader#getCurrentWebApplicationContext()
|
||||
*/
|
||||
@Nullable
|
||||
public static WebApplicationContext findWebApplicationContext(HttpServletRequest request) {
|
||||
return findWebApplicationContext(request, request.getServletContext());
|
||||
}
|
||||
@@ -122,6 +126,7 @@ public abstract class RequestContextUtils {
|
||||
* @param request current HTTP request
|
||||
* @return the current LocaleResolver, or {@code null} if not found
|
||||
*/
|
||||
@Nullable
|
||||
public static LocaleResolver getLocaleResolver(HttpServletRequest request) {
|
||||
return (LocaleResolver) request.getAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE);
|
||||
}
|
||||
@@ -163,6 +168,7 @@ public abstract class RequestContextUtils {
|
||||
* @see #getLocaleResolver
|
||||
* @see org.springframework.context.i18n.LocaleContextHolder#getTimeZone()
|
||||
*/
|
||||
@Nullable
|
||||
public static TimeZone getTimeZone(HttpServletRequest request) {
|
||||
LocaleResolver localeResolver = getLocaleResolver(request);
|
||||
if (localeResolver instanceof LocaleContextResolver) {
|
||||
@@ -180,6 +186,7 @@ public abstract class RequestContextUtils {
|
||||
* @param request current HTTP request
|
||||
* @return the current ThemeResolver, or {@code null} if not found
|
||||
*/
|
||||
@Nullable
|
||||
public static ThemeResolver getThemeResolver(HttpServletRequest request) {
|
||||
return (ThemeResolver) request.getAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE);
|
||||
}
|
||||
@@ -201,6 +208,7 @@ public abstract class RequestContextUtils {
|
||||
* @return the current theme, or {@code null} if not found
|
||||
* @see #getThemeResolver
|
||||
*/
|
||||
@Nullable
|
||||
public static Theme getTheme(HttpServletRequest request) {
|
||||
ThemeResolver themeResolver = getThemeResolver(request);
|
||||
ThemeSource themeSource = getThemeSource(request);
|
||||
@@ -220,6 +228,7 @@ public abstract class RequestContextUtils {
|
||||
* @see FlashMap
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public static Map<String, ?> getInputFlashMap(HttpServletRequest request) {
|
||||
return (Map<String, ?>) request.getAttribute(DispatcherServlet.INPUT_FLASH_MAP_ATTRIBUTE);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,11 @@
|
||||
package org.springframework.web.servlet.support;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A contract for inspecting and potentially modifying request data values such
|
||||
* as URL query parameters or form field values before they are rendered by a
|
||||
@@ -61,6 +64,7 @@ public interface RequestDataValueProcessor {
|
||||
* @param request the current request
|
||||
* @return additional hidden form fields to be added, or {@code null}
|
||||
*/
|
||||
@Nullable
|
||||
Map<String, String> getExtraHiddenFields(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,10 +17,12 @@
|
||||
package org.springframework.web.servlet.support;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
@@ -212,6 +214,7 @@ public class ServletUriComponentsBuilder extends UriComponentsBuilder {
|
||||
* @return the removed path extension for possible re-use, or {@code null}
|
||||
* @since 4.0
|
||||
*/
|
||||
@Nullable
|
||||
public String removePathExtension() {
|
||||
String extension = null;
|
||||
if (this.originalPath != null) {
|
||||
|
||||
@@ -3,4 +3,7 @@
|
||||
* Provides easy evaluation of the request context in views,
|
||||
* and miscellaneous HandlerInterceptor implementations.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.servlet.support;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user