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-core/src/main/java/org/springframework/util/ClassUtils.java b/spring-core/src/main/java/org/springframework/util/ClassUtils.java index e570646f9e..6018cbe107 100644 --- a/spring-core/src/main/java/org/springframework/util/ClassUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ClassUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 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. @@ -88,13 +88,13 @@ public abstract class ClassUtils { * Map with primitive wrapper type as key and corresponding primitive * type as value, for example: Integer.class -> int.class. */ - private static final Map, Class> primitiveWrapperTypeMap = new IdentityHashMap<>(8); + private static final Map, Class> primitiveWrapperTypeMap = new IdentityHashMap<>(9); /** * Map with primitive type as key and corresponding wrapper * type as value, for example: int.class -> Integer.class. */ - private static final Map, Class> primitiveTypeToWrapperMap = new IdentityHashMap<>(8); + private static final Map, Class> primitiveTypeToWrapperMap = new IdentityHashMap<>(9); /** * Map with primitive type name as key and corresponding primitive @@ -1322,7 +1322,7 @@ public abstract class ClassUtils { * Note that, despite being synthetic, bridge methods ({@link Method#isBridge()}) are considered * as user-level methods since they are eventually pointing to a user-declared generic method. * @param method the method to check - * @return {@code true} if the method can be considered as user-declared; [@code false} otherwise + * @return {@code true} if the method can be considered as user-declared; {@code false} otherwise */ public static boolean isUserLevelMethod(Method method) { Assert.notNull(method, "Method must not be null"); diff --git a/spring-core/src/main/java/org/springframework/util/StringUtils.java b/spring-core/src/main/java/org/springframework/util/StringUtils.java index d19cd4bd86..7d56274895 100644 --- a/spring-core/src/main/java/org/springframework/util/StringUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StringUtils.java @@ -565,7 +565,7 @@ public abstract class StringUtils { char[] chars = str.toCharArray(); chars[0] = updatedChar; - return new String(chars, 0, chars.length); + return new String(chars); } /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactory.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactory.java index c3feebc1a0..b3da10249d 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactory.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactory.java @@ -120,8 +120,7 @@ public class DefaultMessageHandlerMethodFactory * the ones configured by default. This is an advanced option. For most use cases * it should be sufficient to use {@link #setCustomArgumentResolvers(java.util.List)}. */ - @SuppressWarnings("ConstantConditions") - public void setArgumentResolvers(List argumentResolvers) { + public void setArgumentResolvers(@Nullable List argumentResolvers) { if (argumentResolvers == null) { this.argumentResolvers.clear(); return; diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java index 7ae1c1bf9c..4865e3bf6f 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java @@ -131,7 +131,6 @@ public class RSocketFrameTypeMessageCondition extends AbstractMessageCondition message) { return (FrameType) message.getHeaders().get(RSocketFrameTypeMessageCondition.FRAME_TYPE_HEADER); diff --git a/spring-web/src/main/java/org/springframework/web/bind/annotation/CookieValue.java b/spring-web/src/main/java/org/springframework/web/bind/annotation/CookieValue.java index d49ffddaf2..9b75d78841 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/annotation/CookieValue.java +++ b/spring-web/src/main/java/org/springframework/web/bind/annotation/CookieValue.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 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. @@ -25,7 +25,7 @@ import java.lang.annotation.Target; import org.springframework.core.annotation.AliasFor; /** - * Annotation which indicates that a method parameter should be bound to an HTTP cookie. + * Annotation to indicate that a method parameter is bound to an HTTP cookie. * *

The method parameter may be declared as type {@link javax.servlet.http.Cookie} * or as cookie value type (String, int, etc.). diff --git a/spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java b/spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java index afea5508c5..3440e05997 100644 --- a/spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java +++ b/spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 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. @@ -59,8 +59,7 @@ public class CorsConfiguration { private static final List DEFAULT_PERMIT_METHODS = Collections.unmodifiableList( Arrays.asList(HttpMethod.GET.name(), HttpMethod.HEAD.name(), HttpMethod.POST.name())); - private static final List DEFAULT_PERMIT_ALL = Collections.unmodifiableList( - Collections.singletonList(ALL)); + private static final List DEFAULT_PERMIT_ALL = Collections.singletonList(ALL); @Nullable 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 55dfa41e4d..bac1e4033a 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 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. @@ -59,7 +59,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 @@ -77,6 +76,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. @@ -97,6 +97,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; } @@ -113,6 +117,7 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini this.detectHandlerFunctionsInAncestorContexts = detectHandlerFunctionsInAncestorContexts; } + @Override public void afterPropertiesSet() throws Exception { if (this.routerFunction == null) { 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 bfda2d4849..bda4042f4c 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 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. @@ -359,6 +359,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 = getUrlPathHelper().getLookupPathForRequest(request); request.setAttribute(LOOKUP_PATH, lookupPath); 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 0d6bd80895..5bd64f3956 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 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. @@ -33,6 +33,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.InvalidMediaTypeException; import org.springframework.http.MediaType; +import org.springframework.lang.Nullable; import org.springframework.util.CollectionUtils; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; @@ -104,6 +105,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/src/docs/asciidoc/core/core-beans.adoc b/src/docs/asciidoc/core/core-beans.adoc index d731b2bde0..f02e860c00 100644 --- a/src/docs/asciidoc/core/core-beans.adoc +++ b/src/docs/asciidoc/core/core-beans.adoc @@ -847,12 +847,12 @@ This approach shows that the factory bean itself can be managed and configured t dependency injection (DI). See <>. -NOTE: In Spring documentation, "`factory bean`" refers to a bean that is configured in -the Spring container and that creates objects through an +NOTE: In Spring documentation, "factory bean" refers to a bean that is configured in the +Spring container and that creates objects through an <> or <> factory method. By contrast, `FactoryBean` (notice the capitalization) refers to a Spring-specific -<> implementation class. +<> implementation class. [[beans-factory-type-determination]] @@ -8279,7 +8279,7 @@ it resembles the following: fun userService(): Service { return SimpleUserService().apply { // a reference to the proxied userPreferences bean - setUserPreferences(userPreferences() + setUserPreferences(userPreferences()) } } ----