Fix overridden methods nullability

Issue: SPR-15869
This commit is contained in:
Sebastien Deleuze
2017-08-17 14:30:14 +02:00
parent 6b6c1d3e53
commit 73cf07e9a4
488 changed files with 1016 additions and 34 deletions

View File

@@ -188,6 +188,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
Object source = parserContext.extractSource(element);
XmlReaderContext readerContext = parserContext.getReaderContext();
@@ -706,6 +707,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
}
@Override
@Nullable
public CompositeUriComponentsContributor getObject() throws Exception {
return this.uriComponentsContributor;
}

View File

@@ -26,6 +26,7 @@ import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.springframework.web.cors.CorsConfiguration;
@@ -42,6 +43,7 @@ import org.springframework.web.cors.CorsConfiguration;
public class CorsBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
Map<String, CorsConfiguration> corsConfigurations = new LinkedHashMap<>();

View File

@@ -26,6 +26,7 @@ import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
@@ -44,6 +45,7 @@ import org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler
class DefaultServletHandlerBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
Object source = parserContext.extractSource(element);

View File

@@ -28,6 +28,7 @@ import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.lang.Nullable;
import org.springframework.util.xml.DomUtils;
import org.springframework.web.servlet.handler.MappedInterceptor;
@@ -41,6 +42,7 @@ import org.springframework.web.servlet.handler.MappedInterceptor;
class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));
parserContext.pushContainingComponent(compDefinition);

View File

@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.MessageCodesResolver;
import org.springframework.validation.Validator;
@@ -133,11 +134,13 @@ public class DelegatingWebMvcConfiguration extends WebMvcConfigurationSupport {
}
@Override
@Nullable
protected Validator getValidator() {
return this.configurers.getValidator();
}
@Override
@Nullable
protected MessageCodesResolver getMessageCodesResolver() {
return this.configurers.getMessageCodesResolver();
}

View File

@@ -20,6 +20,7 @@ import java.util.List;
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;
@@ -172,6 +173,7 @@ public abstract class WebMvcConfigurerAdapter implements WebMvcConfigurer {
* <p>This implementation returns {@code null}.
*/
@Override
@Nullable
public Validator getValidator() {
return null;
}
@@ -181,6 +183,7 @@ public abstract class WebMvcConfigurerAdapter implements WebMvcConfigurer {
* <p>This implementation returns {@code null}.
*/
@Override
@Nullable
public MessageCodesResolver getMessageCodesResolver() {
return null;
}

View File

@@ -21,6 +21,7 @@ import java.util.List;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.MessageCodesResolver;
import org.springframework.validation.Validator;
@@ -175,6 +176,7 @@ class WebMvcConfigurerComposite implements WebMvcConfigurer {
}
@Override
@Nullable
public MessageCodesResolver getMessageCodesResolver() {
MessageCodesResolver selected = null;
for (WebMvcConfigurer configurer : this.delegates) {

View File

@@ -20,7 +20,6 @@ import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextException;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@@ -96,10 +95,8 @@ public abstract class AbstractDetectingUrlHandlerMapping extends AbstractUrlHand
/**
* Determine the URLs for the given handler bean.
* @param beanName the name of the candidate bean
* @return the URLs determined for the bean,
* or {@code null} or an empty array if none
* @return the URLs determined for the bean, or an empty array if none
*/
@Nullable
protected abstract String[] determineUrlsForHandler(String beanName);
}

View File

@@ -128,6 +128,7 @@ public abstract class AbstractHandlerExceptionResolver implements HandlerExcepti
* to the {@link #doResolveException} template method.
*/
@Override
@Nullable
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response,
@Nullable Object handler, Exception ex) {

View File

@@ -346,6 +346,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* @see #getHandlerInternal
*/
@Override
@Nullable
public final HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
Object handler = getHandlerInternal(request);
if (handler == null) {
@@ -488,6 +489,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
}
@Override
@Nullable
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
return this.config;
}
@@ -511,6 +513,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
}
@Override
@Nullable
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
return this.config;
}

View File

@@ -54,6 +54,7 @@ public abstract class AbstractHandlerMethodExceptionResolver extends AbstractHan
}
@Override
@Nullable
protected final ModelAndView doResolveException(
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) {

View File

@@ -294,6 +294,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
}
@Override
@Nullable
public RequestMatchResult match(HttpServletRequest request, String pattern) {
String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
if (getPathMatcher().match(pattern, lookupPath)) {

View File

@@ -144,6 +144,7 @@ public class HandlerMappingIntrospector implements CorsConfigurationSource {
}
@Override
@Nullable
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
HttpServletRequest wrapper = new RequestAttributeChangeIgnoringWrapper(request);
for (HandlerMapping handlerMapping : this.handlerMappings) {

View File

@@ -179,6 +179,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
* @return a corresponding ModelAndView to forward to, or {@code null} for default processing
*/
@Override
@Nullable
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response,
@Nullable Object handler, Exception ex) {

View File

@@ -20,6 +20,7 @@ import javax.servlet.Servlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.HandlerAdapter;
import org.springframework.web.servlet.ModelAndView;
@@ -59,6 +60,7 @@ public class SimpleServletHandlerAdapter implements HandlerAdapter {
}
@Override
@Nullable
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {

View File

@@ -168,10 +168,12 @@ public class CookieLocaleResolver extends CookieGenerator implements LocaleConte
parseLocaleCookieIfNecessary(request);
return new TimeZoneAwareLocaleContext() {
@Override
@Nullable
public Locale getLocale() {
return (Locale) request.getAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME);
}
@Override
@Nullable
public TimeZone getTimeZone() {
return (TimeZone) request.getAttribute(TIME_ZONE_REQUEST_ATTRIBUTE_NAME);
}

View File

@@ -82,6 +82,7 @@ public class FixedLocaleResolver extends AbstractLocaleContextResolver {
public LocaleContext resolveLocaleContext(HttpServletRequest request) {
return new TimeZoneAwareLocaleContext() {
@Override
@Nullable
public Locale getLocale() {
return getDefaultLocale();
}

View File

@@ -127,6 +127,7 @@ public class SessionLocaleResolver extends AbstractLocaleContextResolver {
return locale;
}
@Override
@Nullable
public TimeZone getTimeZone() {
TimeZone timeZone = (TimeZone) WebUtils.getSessionAttribute(request, timeZoneAttributeName);
if (timeZone == null) {

View File

@@ -149,6 +149,7 @@ public abstract class AbstractController extends WebContentGenerator implements
@Override
@Nullable
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {

View File

@@ -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.HttpRequestHandler;
import org.springframework.web.servlet.HandlerAdapter;
import org.springframework.web.servlet.ModelAndView;
@@ -45,6 +46,7 @@ public class HttpRequestHandlerAdapter implements HandlerAdapter {
}
@Override
@Nullable
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {

View File

@@ -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.HandlerAdapter;
import org.springframework.web.servlet.ModelAndView;
@@ -44,6 +45,7 @@ public class SimpleControllerHandlerAdapter implements HandlerAdapter {
}
@Override
@Nullable
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {

View File

@@ -66,6 +66,7 @@ public class ResponseStatusExceptionResolver extends AbstractHandlerExceptionRes
@Override
@Nullable
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response,
@Nullable Object handler, Exception ex) {

View File

@@ -23,6 +23,7 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -142,6 +143,7 @@ public class CompositeRequestCondition extends AbstractRequestCondition<Composit
* <p>An empty {@code CompositeRequestCondition} matches to all requests.
*/
@Override
@Nullable
public CompositeRequestCondition getMatchingCondition(HttpServletRequest request) {
if (isEmpty()) {
return this;

View File

@@ -161,6 +161,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition<Con
* or {@code null} if no expressions match.
*/
@Override
@Nullable
public ConsumesRequestCondition getMatchingCondition(HttpServletRequest request) {
if (CorsUtils.isPreFlightRequest(request)) {
return PRE_FLIGHT_MATCH;

View File

@@ -22,6 +22,7 @@ import java.util.LinkedHashSet;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.cors.CorsUtils;
@@ -107,6 +108,7 @@ public final class HeadersRequestCondition extends AbstractRequestCondition<Head
* or {@code null} otherwise.
*/
@Override
@Nullable
public HeadersRequestCondition getMatchingCondition(HttpServletRequest request) {
if (CorsUtils.isPreFlightRequest(request)) {
return PRE_FLIGHT_MATCH;

View File

@@ -22,6 +22,7 @@ import java.util.LinkedHashSet;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.util.WebUtils;
@@ -95,6 +96,7 @@ public final class ParamsRequestCondition extends AbstractRequestCondition<Param
* or {@code null} otherwise.
*/
@Override
@Nullable
public ParamsRequestCondition getMatchingCondition(HttpServletRequest request) {
for (ParamExpression expression : expressions) {
if (!expression.match(request)) {

View File

@@ -196,6 +196,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
* or {@code null} if no patterns match.
*/
@Override
@Nullable
public PatternsRequestCondition getMatchingCondition(HttpServletRequest request) {
if (this.patterns.isEmpty()) {

View File

@@ -185,6 +185,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
* or {@code null} if no expressions match.
*/
@Override
@Nullable
public ProducesRequestCondition getMatchingCondition(HttpServletRequest request) {
if (CorsUtils.isPreFlightRequest(request)) {
return PRE_FLIGHT_MATCH;

View File

@@ -110,6 +110,7 @@ public final class RequestConditionHolder extends AbstractRequestCondition<Reque
* holder, return the same holder instance.
*/
@Override
@Nullable
public RequestConditionHolder getMatchingCondition(HttpServletRequest request) {
if (this.condition == null) {
return this;

View File

@@ -98,6 +98,7 @@ public final class RequestMethodsRequestCondition extends AbstractRequestConditi
* request method is OPTIONS.
*/
@Override
@Nullable
public RequestMethodsRequestCondition getMatchingCondition(HttpServletRequest request) {
if (CorsUtils.isPreFlightRequest(request)) {
return matchPreFlight(request);

View File

@@ -80,6 +80,7 @@ public abstract class AbstractHandlerMethodAdapter extends WebContentGenerator i
* This implementation expects the handler to be an {@link HandlerMethod}.
*/
@Override
@Nullable
public final ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {

View File

@@ -210,6 +210,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
* @return a new instance in case all conditions match; or {@code null} otherwise
*/
@Override
@Nullable
public RequestMappingInfo getMatchingCondition(HttpServletRequest request) {
RequestMethodsRequestCondition methods = this.methodsCondition.getMatchingCondition(request);
ParamsRequestCondition params = this.paramsCondition.getMatchingCondition(request);

View File

@@ -42,6 +42,7 @@ public abstract class AbstractMappingJacksonResponseBodyAdvice implements Respon
}
@Override
@Nullable
public final Object beforeBodyWrite(@Nullable Object body, MethodParameter returnType,
MediaType contentType, Class<? extends HttpMessageConverter<?>> converterType,
ServerHttpRequest request, ServerHttpResponse response) {

View File

@@ -122,6 +122,7 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
}
@Override
@Nullable
public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory)
throws IOException, HttpMediaTypeNotSupportedException {

View File

@@ -60,6 +60,7 @@ public class MatrixVariableMapMethodArgumentResolver implements HandlerMethodArg
}
@Override
@Nullable
public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer,
NativeWebRequest request, @Nullable WebDataBinderFactory binderFactory) throws Exception {

View File

@@ -21,6 +21,7 @@ import java.util.List;
import java.util.Map;
import org.springframework.core.MethodParameter;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.MultiValueMap;
@@ -71,6 +72,7 @@ public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueMeth
@Override
@SuppressWarnings("unchecked")
@Nullable
protected Object resolveName(String name, MethodParameter parameter, NativeWebRequest request) throws Exception {
Map<String, MultiValueMap<String, String>> pathParameters = (Map<String, MultiValueMap<String, String>>)
request.getAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);

View File

@@ -89,6 +89,7 @@ public class PathVariableMethodArgumentResolver extends AbstractNamedValueMethod
@Override
@SuppressWarnings("unchecked")
@Nullable
protected Object resolveName(String name, MethodParameter parameter, NativeWebRequest request) throws Exception {
Map<String, String> uriTemplateVars = (Map<String, String>) request.getAttribute(
HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);

View File

@@ -19,6 +19,7 @@ package org.springframework.web.servlet.mvc.method.annotation;
import javax.servlet.ServletException;
import org.springframework.core.MethodParameter;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.RequestAttribute;
@@ -48,6 +49,7 @@ public class RequestAttributeMethodArgumentResolver extends AbstractNamedValueMe
}
@Override
@Nullable
protected Object resolveName(String name, MethodParameter parameter, NativeWebRequest request){
return request.getAttribute(name, RequestAttributes.SCOPE_REQUEST);
}

View File

@@ -187,6 +187,7 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
* @see #getCustomTypeCondition(Class)
*/
@Override
@Nullable
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
RequestMappingInfo info = createRequestMappingInfo(method);
if (info != null) {
@@ -205,6 +206,7 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
* @see #getCustomTypeCondition(Class)
* @see #getCustomMethodCondition(Method)
*/
@Nullable
private RequestMappingInfo createRequestMappingInfo(AnnotatedElement element) {
RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(element, RequestMapping.class);
RequestCondition<?> condition = (element instanceof Class ?

View File

@@ -108,6 +108,7 @@ public class RequestPartMethodArgumentResolver extends AbstractMessageConverterM
}
@Override
@Nullable
public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer,
NativeWebRequest request, @Nullable WebDataBinderFactory binderFactory) throws Exception {

View File

@@ -104,6 +104,7 @@ class RequestResponseBodyAdviceChain implements RequestBodyAdvice, ResponseBodyA
}
@Override
@Nullable
public Object beforeBodyWrite(@Nullable Object body, MethodParameter returnType, MediaType contentType,
Class<? extends HttpMessageConverter<?>> converterType,
ServerHttpRequest request, ServerHttpResponse response) {
@@ -112,6 +113,7 @@ class RequestResponseBodyAdviceChain implements RequestBodyAdvice, ResponseBodyA
}
@Override
@Nullable
public Object handleEmptyBody(@Nullable Object body, HttpInputMessage inputMessage, MethodParameter parameter,
Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {

View File

@@ -51,6 +51,7 @@ public class ServletCookieValueMethodArgumentResolver extends AbstractCookieValu
@Override
@Nullable
protected Object resolveName(String cookieName, MethodParameter parameter, NativeWebRequest webRequest) throws Exception {
HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
Assert.state(servletRequest != null, "No HttpServletRequest");

View File

@@ -19,6 +19,7 @@ package org.springframework.web.servlet.mvc.method.annotation;
import javax.servlet.ServletException;
import org.springframework.core.MethodParameter;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.SessionAttribute;
@@ -48,6 +49,7 @@ public class SessionAttributeMethodArgumentResolver extends AbstractNamedValueMe
}
@Override
@Nullable
protected Object resolveName(String name, MethodParameter parameter, NativeWebRequest request){
return request.getAttribute(name, RequestAttributes.SCOPE_SESSION);
}

View File

@@ -101,6 +101,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
@Override
@Nullable
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response,
@Nullable Object handler, Exception ex) {

View File

@@ -38,6 +38,7 @@ public abstract class AbstractResourceResolver implements ResourceResolver {
@Override
@Nullable
public Resource resolveResource(@Nullable HttpServletRequest request, String requestPath,
List<? extends Resource> locations, ResourceResolverChain chain) {
@@ -48,6 +49,7 @@ public abstract class AbstractResourceResolver implements ResourceResolver {
}
@Override
@Nullable
public String resolveUrlPath(String resourceUrlPath, List<? extends Resource> locations,
ResourceResolverChain chain) {

View File

@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
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.StringUtils;
@@ -60,6 +61,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
@Override
@Nullable
public String extractVersion(String requestPath) {
return this.pathStrategy.extractVersion(requestPath);
}
@@ -89,6 +91,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
}
@Override
@Nullable
public String extractVersion(String requestPath) {
return (requestPath.startsWith(this.prefix) ? this.prefix : null);
}
@@ -120,6 +123,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
private static final Pattern pattern = Pattern.compile("-(\\S*)\\.");
@Override
@Nullable
public String extractVersion(String requestPath) {
Matcher matcher = pattern.matcher(requestPath);
if (matcher.find()) {

View File

@@ -48,6 +48,7 @@ class DefaultResourceResolverChain implements ResourceResolverChain {
@Override
@Nullable
public Resource resolveResource(
@Nullable HttpServletRequest request, String requestPath, List<? extends Resource> locations) {
@@ -65,6 +66,7 @@ class DefaultResourceResolverChain implements ResourceResolverChain {
}
@Override
@Nullable
public String resolveUrlPath(String resourcePath, List<? extends Resource> locations) {
ResourceResolver resolver = getNext();
if (resolver == null) {

View File

@@ -89,18 +89,22 @@ public class GzipResourceResolver extends AbstractResourceResolver {
this.gzipped = original.createRelative(original.getFilename() + ".gz");
}
@Override
public InputStream getInputStream() throws IOException {
return this.gzipped.getInputStream();
}
@Override
public boolean exists() {
return this.gzipped.exists();
}
@Override
public boolean isReadable() {
return this.gzipped.isReadable();
}
@Override
public boolean isOpen() {
return this.gzipped.isOpen();
}
@@ -110,34 +114,43 @@ public class GzipResourceResolver extends AbstractResourceResolver {
return this.gzipped.isFile();
}
@Override
public URL getURL() throws IOException {
return this.gzipped.getURL();
}
@Override
public URI getURI() throws IOException {
return this.gzipped.getURI();
}
@Override
public File getFile() throws IOException {
return this.gzipped.getFile();
}
@Override
public long contentLength() throws IOException {
return this.gzipped.contentLength();
}
@Override
public long lastModified() throws IOException {
return this.gzipped.lastModified();
}
@Override
public Resource createRelative(String relativePath) throws IOException {
return this.gzipped.createRelative(relativePath);
}
@Override
@Nullable
public String getFilename() {
return this.original.getFilename();
}
@Override
public String getDescription() {
return this.gzipped.getDescription();
}

View File

@@ -244,6 +244,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
* Return the specified CORS configuration.
*/
@Override
@Nullable
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
return this.corsConfiguration;
}

View File

@@ -295,6 +295,7 @@ public class VersionResourceResolver extends AbstractResourceResolver {
}
@Override
@Nullable
public String getFilename() {
return this.original.getFilename();
}

View File

@@ -88,6 +88,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
@Override
@Nullable
public final FlashMap retrieveAndUpdate(HttpServletRequest request, HttpServletResponse response) {
List<FlashMap> allFlashMaps = retrieveFlashMaps(request);
if (CollectionUtils.isEmpty(allFlashMaps)) {

View File

@@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.FlashMap;
import org.springframework.web.util.WebUtils;
@@ -41,6 +42,7 @@ public class SessionFlashMapManager extends AbstractFlashMapManager {
*/
@Override
@SuppressWarnings("unchecked")
@Nullable
protected List<FlashMap> retrieveFlashMaps(HttpServletRequest request) {
HttpSession session = request.getSession(false);
return (session != null ? (List<FlashMap>) session.getAttribute(FLASH_MAPS_SESSION_ATTRIBUTE) : null);

View File

@@ -184,6 +184,7 @@ public class BindTag extends HtmlEscapingAwareTag implements EditorAwareTag {
}
@Override
@Nullable
public final PropertyEditor getEditor() {
return getStatus().getEditor();
}

View File

@@ -168,6 +168,7 @@ public class EvalTag extends HtmlEscapingAwareTag {
}
@Override
@Nullable
public Class<?>[] getSpecificTargetClasses() {
return null;
}

View File

@@ -198,6 +198,7 @@ public abstract class AbstractDataBoundFormElementTag extends AbstractFormTag im
* Get the bound value.
* @see #getBindStatus()
*/
@Nullable
protected final Object getBoundValue() throws JspException {
return getBindStatus().getValue();
}
@@ -215,6 +216,7 @@ public abstract class AbstractDataBoundFormElementTag extends AbstractFormTag im
* <p>Use {@link #getPropertyEditor()} for internal rendering purposes.
*/
@Override
@Nullable
public final PropertyEditor getEditor() throws JspException {
return getPropertyEditor();
}

View File

@@ -50,6 +50,7 @@ public abstract class AbstractCachingViewResolver extends WebApplicationObjectSu
/** Dummy marker object for unresolved views in the cache Maps */
private static final View UNRESOLVED_VIEW = new View() {
@Override
@Nullable
public String getContentType() {
return null;
}
@@ -143,6 +144,7 @@ public abstract class AbstractCachingViewResolver extends WebApplicationObjectSu
@Override
@Nullable
public View resolveViewName(String viewName, Locale locale) throws Exception {
if (!isCache()) {
return createView(viewName, locale);

View File

@@ -21,6 +21,7 @@ import java.util.Locale;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.web.context.support.WebApplicationObjectSupport;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;
@@ -67,6 +68,7 @@ public class BeanNameViewResolver extends WebApplicationObjectSupport implements
@Override
@Nullable
public View resolveViewName(String viewName, Locale locale) throws BeansException {
ApplicationContext context = obtainApplicationContext();
if (!context.containsBean(viewName)) {

View File

@@ -219,6 +219,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport
@Override
@Nullable
public View resolveViewName(String viewName, Locale locale) throws Exception {
RequestAttributes attrs = RequestContextHolder.getRequestAttributes();
Assert.state(attrs instanceof ServletRequestAttributes, "No current ServletRequestAttributes");
@@ -364,6 +365,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport
private static final View NOT_ACCEPTABLE_VIEW = new View() {
@Override
@Nullable
public String getContentType() {
return null;
}

View File

@@ -27,6 +27,7 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
import org.springframework.web.context.ServletContextAware;
import org.springframework.web.servlet.View;
@@ -101,6 +102,7 @@ public class ViewResolverComposite implements ViewResolver, Ordered, Initializin
}
@Override
@Nullable
public View resolveViewName(String viewName, Locale locale) throws Exception {
for (ViewResolver viewResolver : this.viewResolvers) {
View view = viewResolver.resolveViewName(viewName, locale);