diff --git a/spring-context/src/main/java/org/springframework/validation/support/BindingAwareConcurrentModel.java b/spring-context/src/main/java/org/springframework/validation/support/BindingAwareConcurrentModel.java index 61014d0159..3411f9a909 100644 --- a/spring-context/src/main/java/org/springframework/validation/support/BindingAwareConcurrentModel.java +++ b/spring-context/src/main/java/org/springframework/validation/support/BindingAwareConcurrentModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.validation.support; import java.util.Map; +import org.springframework.lang.Nullable; import org.springframework.ui.ConcurrentModel; import org.springframework.validation.BindingResult; @@ -36,17 +37,19 @@ import org.springframework.validation.BindingResult; * @author Rossen Stoyanchev * @since 5.0 * @see BindingResult + * @see BindingAwareModelMap */ @SuppressWarnings("serial") public class BindingAwareConcurrentModel extends ConcurrentModel { @Override - public Object put(String key, Object value) { + @Nullable + public Object put(String key, @Nullable Object value) { removeBindingResultIfNecessary(key, value); return super.put(key, value); } - private void removeBindingResultIfNecessary(String key, Object value) { + private void removeBindingResultIfNecessary(String key, @Nullable Object value) { if (!key.startsWith(BindingResult.MODEL_KEY_PREFIX)) { String resultKey = BindingResult.MODEL_KEY_PREFIX + key; BindingResult result = (BindingResult) get(resultKey); diff --git a/spring-context/src/main/java/org/springframework/validation/support/BindingAwareModelMap.java b/spring-context/src/main/java/org/springframework/validation/support/BindingAwareModelMap.java index cfde93a0d2..9ac97145ba 100644 --- a/spring-context/src/main/java/org/springframework/validation/support/BindingAwareModelMap.java +++ b/spring-context/src/main/java/org/springframework/validation/support/BindingAwareModelMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.validation.support; import java.util.Map; +import org.springframework.lang.Nullable; import org.springframework.ui.ExtendedModelMap; import org.springframework.validation.BindingResult; @@ -39,7 +40,7 @@ import org.springframework.validation.BindingResult; public class BindingAwareModelMap extends ExtendedModelMap { @Override - public Object put(String key, Object value) { + public Object put(String key, @Nullable Object value) { removeBindingResultIfNecessary(key, value); return super.put(key, value); } @@ -50,7 +51,7 @@ public class BindingAwareModelMap extends ExtendedModelMap { super.putAll(map); } - private void removeBindingResultIfNecessary(Object key, Object value) { + private void removeBindingResultIfNecessary(Object key, @Nullable Object value) { if (key instanceof String) { String attributeName = (String) key; if (!attributeName.startsWith(BindingResult.MODEL_KEY_PREFIX)) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java index 59d21f4a70..7597f0af68 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java @@ -73,7 +73,6 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini private boolean detectHandlerFunctionsInAncestorContexts = false; - /** * Create an empty {@code RouterFunctionMapping}. *

If this constructor is used, this mapping will detect all @@ -91,6 +90,7 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini this.routerFunction = routerFunction; } + /** * Set the router function to map to. *

If this property is used, no application context detection will occur. @@ -111,6 +111,10 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini return this.routerFunction; } + /** + * Set the message body converters to use. + *

These converters are used to convert from and to HTTP requests and responses. + */ public void setMessageConverters(List> messageConverters) { this.messageConverters = messageConverters; } @@ -127,6 +131,7 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini this.detectHandlerFunctionsInAncestorContexts = detectHandlerFunctionsInAncestorContexts; } + @Override public void afterPropertiesSet() throws Exception { if (this.routerFunction == null) { @@ -204,8 +209,9 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini this.messageConverters = messageConverters; } - @Nullable + @Override + @Nullable protected Object getHandlerInternal(HttpServletRequest servletRequest) throws Exception { if (this.routerFunction != null) { ServerRequest request = ServerRequest.create(servletRequest, this.messageConverters); @@ -219,8 +225,10 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini } private void setAttributes(HttpServletRequest servletRequest, ServerRequest request, - HandlerFunction handlerFunction) { - PathPattern matchingPattern = (PathPattern) servletRequest.getAttribute(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE); + @Nullable HandlerFunction handlerFunction) { + + PathPattern matchingPattern = + (PathPattern) servletRequest.getAttribute(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE); if (matchingPattern != null) { servletRequest.removeAttribute(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE); servletRequest.setAttribute(BEST_MATCHING_PATTERN_ATTRIBUTE, matchingPattern.getPatternString()); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java index e15df8846d..f0e70267d1 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java @@ -369,6 +369,7 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap * Look up a handler method for the given request. */ @Override + @Nullable protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception { String lookupPath = initLookupPath(request); this.mappingRegistry.acquireReadLock(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java index 254deb9128..8758e7cc76 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java @@ -34,6 +34,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.InvalidMediaTypeException; import org.springframework.http.MediaType; import org.springframework.http.server.PathContainer; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import org.springframework.util.MultiValueMap; @@ -117,6 +118,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe } @Override + @Nullable protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception { request.removeAttribute(PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE); try { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHandlerMapping.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHandlerMapping.java index 1ce49177a5..47a66b6299 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHandlerMapping.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHandlerMapping.java @@ -97,11 +97,12 @@ public class WebSocketHandlerMapping extends SimpleUrlHandlerMapping implements return this.running; } - @Nullable + @Override + @Nullable protected Object getHandlerInternal(HttpServletRequest request) throws Exception { Object handler = super.getHandlerInternal(request); - return matchWebSocketUpgrade(handler, request) ? handler : null; + return (matchWebSocketUpgrade(handler, request) ? handler : null); } private boolean matchWebSocketUpgrade(@Nullable Object handler, HttpServletRequest request) {