Browse Source

Improve null-safety to fix some Spring Boot warnings

Issue: SPR-15540
pull/1435/merge
Sebastien Deleuze 8 years ago
parent
commit
c3e6afb879
  1. 4
      spring-beans/src/main/java/org/springframework/beans/factory/NoSuchBeanDefinitionException.java
  2. 10
      spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java
  3. 3
      spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableListableBeanFactory.java
  4. 2
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
  5. 3
      spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionRegistry.java
  6. 4
      spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
  7. 10
      spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java
  8. 3
      spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleBeanDefinitionRegistry.java
  9. 2
      spring-context/src/main/java/org/springframework/context/support/GenericApplicationContext.java
  10. 7
      spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java
  11. 2
      spring-core/src/main/java/org/springframework/core/env/PropertySourcesPropertyResolver.java
  12. 1
      spring-core/src/main/java/org/springframework/lang/NonNullApi.java
  13. 3
      spring-core/src/main/java/org/springframework/util/ReflectionUtils.java
  14. 2
      spring-core/src/main/java/org/springframework/util/StringUtils.java
  15. 2
      spring-web/src/main/java/org/springframework/web/context/WebApplicationContext.java
  16. 15
      spring-web/src/main/java/org/springframework/web/util/HtmlUtils.java
  17. 14
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java
  18. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerExecutionChain.java
  19. 14
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java

4
spring-beans/src/main/java/org/springframework/beans/factory/NoSuchBeanDefinitionException.java

@ -18,6 +18,7 @@ package org.springframework.beans.factory; @@ -18,6 +18,7 @@ package org.springframework.beans.factory;
import org.springframework.beans.BeansException;
import org.springframework.core.ResolvableType;
import org.springframework.lang.Nullable;
/**
* Exception thrown when a {@code BeanFactory} is asked for a bean instance for which it
@ -100,6 +101,7 @@ public class NoSuchBeanDefinitionException extends BeansException { @@ -100,6 +101,7 @@ public class NoSuchBeanDefinitionException extends BeansException {
/**
* Return the name of the missing bean, if it was a lookup <em>by name</em> that failed.
*/
@Nullable
public String getBeanName() {
return this.beanName;
}
@ -108,6 +110,7 @@ public class NoSuchBeanDefinitionException extends BeansException { @@ -108,6 +110,7 @@ public class NoSuchBeanDefinitionException extends BeansException {
* Return the required type of the missing bean, if it was a lookup <em>by type</em>
* that failed.
*/
@Nullable
public Class<?> getBeanType() {
return (this.resolvableType != null ? this.resolvableType.resolve() : null);
}
@ -117,6 +120,7 @@ public class NoSuchBeanDefinitionException extends BeansException { @@ -117,6 +120,7 @@ public class NoSuchBeanDefinitionException extends BeansException {
* <em>by type</em> that failed.
* @since 4.3.4
*/
@Nullable
public ResolvableType getResolvableType() {
return this.resolvableType;
}

10
spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
package org.springframework.beans.factory;
import org.springframework.beans.BeansException;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
/**
@ -42,7 +43,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException { @@ -42,7 +43,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException {
* @param msg the detail message
*/
public UnsatisfiedDependencyException(
String resourceDescription, String beanName, String propertyName, String msg) {
@Nullable String resourceDescription, @Nullable String beanName, String propertyName, String msg) {
super(resourceDescription, beanName,
"Unsatisfied dependency expressed through bean property '" + propertyName + "'" +
@ -57,7 +58,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException { @@ -57,7 +58,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException {
* @param ex the bean creation exception that indicated the unsatisfied dependency
*/
public UnsatisfiedDependencyException(
String resourceDescription, String beanName, String propertyName, BeansException ex) {
@Nullable String resourceDescription, @Nullable String beanName, String propertyName, BeansException ex) {
this(resourceDescription, beanName, propertyName, "");
initCause(ex);
@ -72,7 +73,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException { @@ -72,7 +73,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException {
* @since 4.3
*/
public UnsatisfiedDependencyException(
String resourceDescription, String beanName, InjectionPoint injectionPoint, String msg) {
@Nullable String resourceDescription, @Nullable String beanName, @Nullable InjectionPoint injectionPoint, String msg) {
super(resourceDescription, beanName,
"Unsatisfied dependency expressed through " + injectionPoint +
@ -89,7 +90,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException { @@ -89,7 +90,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException {
* @since 4.3
*/
public UnsatisfiedDependencyException(
String resourceDescription, String beanName, InjectionPoint injectionPoint, BeansException ex) {
@Nullable String resourceDescription, @Nullable String beanName, @Nullable InjectionPoint injectionPoint, BeansException ex) {
this(resourceDescription, beanName, injectionPoint, "");
initCause(ex);
@ -100,6 +101,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException { @@ -100,6 +101,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException {
* Return the injection point (field or method/constructor parameter), if known.
* @since 4.3
*/
@Nullable
public InjectionPoint getInjectionPoint() {
return this.injectionPoint;
}

3
spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableListableBeanFactory.java

@ -21,6 +21,7 @@ import java.util.Iterator; @@ -21,6 +21,7 @@ import java.util.Iterator;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.lang.Nullable;
/**
* Configuration interface to be implemented by most listable bean factories.
@ -105,7 +106,7 @@ public interface ConfigurableListableBeanFactory @@ -105,7 +106,7 @@ public interface ConfigurableListableBeanFactory
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
* defined in this factory
*/
BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException;
BeanDefinition getBeanDefinition(@Nullable String beanName) throws NoSuchBeanDefinitionException;
/**
* Return a unified view over all bean names managed by this factory.

2
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

@ -1738,7 +1738,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @@ -1738,7 +1738,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
* @see ChildBeanDefinition
* @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory#getBeanDefinition
*/
protected abstract BeanDefinition getBeanDefinition(String beanName) throws BeansException;
protected abstract BeanDefinition getBeanDefinition(@Nullable String beanName) throws BeansException;
/**
* Create a bean instance for the given merged bean definition (and arguments).

3
spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionRegistry.java

@ -20,6 +20,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException; @@ -20,6 +20,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.core.AliasRegistry;
import org.springframework.lang.Nullable;
/**
* Interface for registries that hold bean definitions, for example RootBeanDefinition
@ -74,7 +75,7 @@ public interface BeanDefinitionRegistry extends AliasRegistry { @@ -74,7 +75,7 @@ public interface BeanDefinitionRegistry extends AliasRegistry {
* @return the BeanDefinition for the given name (never {@code null})
* @throws NoSuchBeanDefinitionException if there is no such bean definition
*/
BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException;
BeanDefinition getBeanDefinition(@Nullable String beanName) throws NoSuchBeanDefinitionException;
/**
* Check if this registry contains a bean definition with the given name.

4
spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

@ -195,7 +195,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto @@ -195,7 +195,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
* Specify an id for serialization purposes, allowing this BeanFactory to be
* deserialized from this id back into the BeanFactory object, if needed.
*/
public void setSerializationId(String serializationId) {
public void setSerializationId(@Nullable String serializationId) {
if (serializationId != null) {
serializableFactories.put(serializationId, new WeakReference<>(this));
}
@ -671,7 +671,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto @@ -671,7 +671,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
}
@Override
public BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException {
public BeanDefinition getBeanDefinition(@Nullable String beanName) throws NoSuchBeanDefinitionException {
BeanDefinition bd = this.beanDefinitionMap.get(beanName);
if (bd == null) {
if (this.logger.isTraceEnabled()) {

10
spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java

@ -117,7 +117,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition { @@ -117,7 +117,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
* @param beanClass the class of the bean to instantiate
* @see #setBeanClass
*/
public RootBeanDefinition(Class<?> beanClass) {
public RootBeanDefinition(@Nullable Class<?> beanClass) {
super();
setBeanClass(beanClass);
}
@ -131,7 +131,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition { @@ -131,7 +131,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
* @since 5.0
* @see #setInstanceSupplier
*/
public <T> RootBeanDefinition(Class<T> beanClass, Supplier<T> instanceSupplier) {
public <T> RootBeanDefinition(@Nullable Class<T> beanClass, @Nullable Supplier<T> instanceSupplier) {
super();
setBeanClass(beanClass);
setInstanceSupplier(instanceSupplier);
@ -147,7 +147,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition { @@ -147,7 +147,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
* @since 5.0
* @see #setInstanceSupplier
*/
public <T> RootBeanDefinition(Class<T> beanClass, String scope, Supplier<T> instanceSupplier) {
public <T> RootBeanDefinition(@Nullable Class<T> beanClass, String scope, @Nullable Supplier<T> instanceSupplier) {
super();
setBeanClass(beanClass);
setScope(scope);
@ -162,7 +162,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition { @@ -162,7 +162,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
* @param dependencyCheck whether to perform a dependency check for objects
* (not applicable to autowiring a constructor, thus ignored there)
*/
public RootBeanDefinition(Class<?> beanClass, int autowireMode, boolean dependencyCheck) {
public RootBeanDefinition(@Nullable Class<?> beanClass, int autowireMode, boolean dependencyCheck) {
super();
setBeanClass(beanClass);
setAutowireMode(autowireMode);
@ -178,7 +178,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition { @@ -178,7 +178,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
* @param cargs the constructor argument values to apply
* @param pvs the property values to apply
*/
public RootBeanDefinition(Class<?> beanClass, ConstructorArgumentValues cargs, MutablePropertyValues pvs) {
public RootBeanDefinition(@Nullable Class<?> beanClass, ConstructorArgumentValues cargs, MutablePropertyValues pvs) {
super(cargs, pvs);
setBeanClass(beanClass);
}

3
spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleBeanDefinitionRegistry.java

@ -23,6 +23,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException; @@ -23,6 +23,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.core.SimpleAliasRegistry;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@ -57,7 +58,7 @@ public class SimpleBeanDefinitionRegistry extends SimpleAliasRegistry implements @@ -57,7 +58,7 @@ public class SimpleBeanDefinitionRegistry extends SimpleAliasRegistry implements
}
@Override
public BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException {
public BeanDefinition getBeanDefinition(@Nullable String beanName) throws NoSuchBeanDefinitionException {
BeanDefinition bd = this.beanDefinitionMap.get(beanName);
if (bd == null) {
throw new NoSuchBeanDefinitionException(beanName);

2
spring-context/src/main/java/org/springframework/context/support/GenericApplicationContext.java

@ -330,7 +330,7 @@ public class GenericApplicationContext extends AbstractApplicationContext implem @@ -330,7 +330,7 @@ public class GenericApplicationContext extends AbstractApplicationContext implem
}
@Override
public BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException {
public BeanDefinition getBeanDefinition(@Nullable String beanName) throws NoSuchBeanDefinitionException {
return this.beanFactory.getBeanDefinition(beanName);
}

7
spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java

@ -231,7 +231,7 @@ public abstract class AnnotationUtils { @@ -231,7 +231,7 @@ public abstract class AnnotationUtils {
* @see AnnotatedElement#getAnnotations()
*/
@Nullable
public static Annotation[] getAnnotations(AnnotatedElement annotatedElement) {
public static Annotation[] getAnnotations(@Nullable AnnotatedElement annotatedElement) {
try {
return synthesizeAnnotationArray(annotatedElement.getAnnotations(), annotatedElement);
}
@ -1441,7 +1441,7 @@ public abstract class AnnotationUtils { @@ -1441,7 +1441,7 @@ public abstract class AnnotationUtils {
}
@SuppressWarnings("unchecked")
static <A extends Annotation> A synthesizeAnnotation(A annotation, Object annotatedElement) {
static <A extends Annotation> A synthesizeAnnotation(A annotation, @Nullable Object annotatedElement) {
if (annotation == null) {
return null;
}
@ -1548,8 +1548,7 @@ public abstract class AnnotationUtils { @@ -1548,8 +1548,7 @@ public abstract class AnnotationUtils {
* @see #synthesizeAnnotation(Annotation, AnnotatedElement)
* @see #synthesizeAnnotation(Map, Class, AnnotatedElement)
*/
@Nullable
static Annotation[] synthesizeAnnotationArray(@Nullable Annotation[] annotations, @Nullable Object annotatedElement) {
static Annotation[] synthesizeAnnotationArray(Annotation[] annotations, @Nullable Object annotatedElement) {
if (annotations == null) {
return null;
}

2
spring-core/src/main/java/org/springframework/core/env/PropertySourcesPropertyResolver.java vendored

@ -38,7 +38,7 @@ public class PropertySourcesPropertyResolver extends AbstractPropertyResolver { @@ -38,7 +38,7 @@ public class PropertySourcesPropertyResolver extends AbstractPropertyResolver {
* Create a new resolver against the given property sources.
* @param propertySources the set of {@link PropertySource} objects to use
*/
public PropertySourcesPropertyResolver(PropertySources propertySources) {
public PropertySourcesPropertyResolver(@Nullable PropertySources propertySources) {
this.propertySources = propertySources;
}

1
spring-core/src/main/java/org/springframework/lang/NonNullApi.java

@ -18,6 +18,7 @@ import javax.annotation.meta.TypeQualifierDefault; @@ -18,6 +18,7 @@ import javax.annotation.meta.TypeQualifierDefault;
*
* @author Sebastien Deleuze
* @since 5.0
* @see NonNull
* @see javax.annotation.Nonnull
*/
@Documented

3
spring-core/src/main/java/org/springframework/util/ReflectionUtils.java

@ -140,7 +140,8 @@ public abstract class ReflectionUtils { @@ -140,7 +140,8 @@ public abstract class ReflectionUtils {
* @param target the target object from which to get the field
* @return the field's current value
*/
public static Object getField(Field field, Object target) {
@Nullable
public static Object getField(Field field, @Nullable Object target) {
try {
return field.get(target);
}

2
spring-core/src/main/java/org/springframework/util/StringUtils.java

@ -978,7 +978,7 @@ public abstract class StringUtils { @@ -978,7 +978,7 @@ public abstract class StringUtils {
* @param array the original {@code String} array
* @return the resulting array (of the same size) with trimmed elements
*/
public static String[] trimArrayElements(String[] array) {
public static String[] trimArrayElements(@Nullable String[] array) {
if (ObjectUtils.isEmpty(array)) {
return new String[0];
}

2
spring-web/src/main/java/org/springframework/web/context/WebApplicationContext.java

@ -19,6 +19,7 @@ package org.springframework.web.context; @@ -19,6 +19,7 @@ package org.springframework.web.context;
import javax.servlet.ServletContext;
import org.springframework.context.ApplicationContext;
import org.springframework.lang.Nullable;
/**
* Interface to provide configuration for a web application. This is read-only while
@ -100,6 +101,7 @@ public interface WebApplicationContext extends ApplicationContext { @@ -100,6 +101,7 @@ public interface WebApplicationContext extends ApplicationContext {
* Return the standard Servlet API ServletContext for this application.
* <p>Also available for a Portlet application, in addition to the PortletContext.
*/
@Nullable
ServletContext getServletContext();
}

15
spring-web/src/main/java/org/springframework/web/util/HtmlUtils.java

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
package org.springframework.web.util;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@ -58,7 +59,7 @@ public abstract class HtmlUtils { @@ -58,7 +59,7 @@ public abstract class HtmlUtils {
* @param input the (unescaped) input string
* @return the escaped string
*/
public static String htmlEscape(String input) {
public static String htmlEscape(@Nullable String input) {
return htmlEscape(input, WebUtils.DEFAULT_CHARACTER_ENCODING);
}
@ -78,7 +79,7 @@ public abstract class HtmlUtils { @@ -78,7 +79,7 @@ public abstract class HtmlUtils {
* @return the escaped string
* @since 4.1.2
*/
public static String htmlEscape(String input, String encoding) {
public static String htmlEscape(@Nullable String input, String encoding) {
Assert.notNull(encoding, "Encoding is required");
if (input == null) {
return null;
@ -109,7 +110,7 @@ public abstract class HtmlUtils { @@ -109,7 +110,7 @@ public abstract class HtmlUtils {
* @param input the (unescaped) input string
* @return the escaped string
*/
public static String htmlEscapeDecimal(String input) {
public static String htmlEscapeDecimal(@Nullable String input) {
return htmlEscapeDecimal(input, WebUtils.DEFAULT_CHARACTER_ENCODING);
}
@ -129,7 +130,7 @@ public abstract class HtmlUtils { @@ -129,7 +130,7 @@ public abstract class HtmlUtils {
* @return the escaped string
* @since 4.1.2
*/
public static String htmlEscapeDecimal(String input, String encoding) {
public static String htmlEscapeDecimal(@Nullable String input, String encoding) {
Assert.notNull(encoding, "Encoding is required");
if (input == null) {
return null;
@ -161,7 +162,7 @@ public abstract class HtmlUtils { @@ -161,7 +162,7 @@ public abstract class HtmlUtils {
* @param input the (unescaped) input string
* @return the escaped string
*/
public static String htmlEscapeHex(String input) {
public static String htmlEscapeHex(@Nullable String input) {
return htmlEscapeHex(input, WebUtils.DEFAULT_CHARACTER_ENCODING);
}
@ -181,7 +182,7 @@ public abstract class HtmlUtils { @@ -181,7 +182,7 @@ public abstract class HtmlUtils {
* @return the escaped string
* @since 4.1.2
*/
public static String htmlEscapeHex(String input, String encoding) {
public static String htmlEscapeHex(@Nullable String input, String encoding) {
Assert.notNull(encoding, "Encoding is required");
if (input == null) {
return null;
@ -220,7 +221,7 @@ public abstract class HtmlUtils { @@ -220,7 +221,7 @@ public abstract class HtmlUtils {
* @param input the (escaped) input string
* @return the unescaped string
*/
public static String htmlUnescape(String input) {
public static String htmlUnescape(@Nullable String input) {
if (input == null) {
return null;
}

14
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java

@ -69,9 +69,9 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping @@ -69,9 +69,9 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
private final RequestConditionHolder customConditionHolder;
public RequestMappingInfo(String name, PatternsRequestCondition patterns, RequestMethodsRequestCondition methods,
ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes,
ProducesRequestCondition produces, RequestCondition<?> custom) {
public RequestMappingInfo(@Nullable String name, @Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods,
@Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
@Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {
this.name = (StringUtils.hasText(name) ? name : null);
this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition());
@ -86,9 +86,9 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping @@ -86,9 +86,9 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
/**
* Creates a new instance with the given request conditions.
*/
public RequestMappingInfo(PatternsRequestCondition patterns, RequestMethodsRequestCondition methods,
ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes,
ProducesRequestCondition produces, RequestCondition<?> custom) {
public RequestMappingInfo(@Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods,
@Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
@Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {
this(null, patterns, methods, params, headers, consumes, produces, custom);
}
@ -96,7 +96,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping @@ -96,7 +96,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
/**
* Re-create a RequestMappingInfo with the given custom request condition.
*/
public RequestMappingInfo(RequestMappingInfo info, RequestCondition<?> customRequestCondition) {
public RequestMappingInfo(RequestMappingInfo info, @Nullable RequestCondition<?> customRequestCondition) {
this(info.name, info.patternsCondition, info.methodsCondition, info.paramsCondition, info.headersCondition,
info.consumesCondition, info.producesCondition, customRequestCondition);
}

4
spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerExecutionChain.java

@ -54,7 +54,7 @@ public class HandlerExecutionChain { @@ -54,7 +54,7 @@ public class HandlerExecutionChain {
* Create a new HandlerExecutionChain.
* @param handler the handler object to execute
*/
public HandlerExecutionChain(Object handler) {
public HandlerExecutionChain(@Nullable Object handler) {
this(handler, (HandlerInterceptor[]) null);
}
@ -64,7 +64,7 @@ public class HandlerExecutionChain { @@ -64,7 +64,7 @@ public class HandlerExecutionChain {
* @param interceptors the array of interceptors to apply
* (in the given order) before the handler itself executes
*/
public HandlerExecutionChain(Object handler, HandlerInterceptor... interceptors) {
public HandlerExecutionChain(@Nullable Object handler, HandlerInterceptor... interceptors) {
if (handler instanceof HandlerExecutionChain) {
HandlerExecutionChain originalChain = (HandlerExecutionChain) handler;
this.handler = originalChain.getHandler();

14
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java

@ -71,9 +71,9 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping @@ -71,9 +71,9 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
private final RequestConditionHolder customConditionHolder;
public RequestMappingInfo(String name, PatternsRequestCondition patterns, RequestMethodsRequestCondition methods,
ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes,
ProducesRequestCondition produces, RequestCondition<?> custom) {
public RequestMappingInfo(@Nullable String name, @Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods,
@Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
@Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {
this.name = (StringUtils.hasText(name) ? name : null);
this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition());
@ -88,9 +88,9 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping @@ -88,9 +88,9 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
/**
* Creates a new instance with the given request conditions.
*/
public RequestMappingInfo(PatternsRequestCondition patterns, RequestMethodsRequestCondition methods,
ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes,
ProducesRequestCondition produces, RequestCondition<?> custom) {
public RequestMappingInfo(@Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods,
@Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
@Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {
this(null, patterns, methods, params, headers, consumes, produces, custom);
}
@ -98,7 +98,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping @@ -98,7 +98,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
/**
* Re-create a RequestMappingInfo with the given custom request condition.
*/
public RequestMappingInfo(RequestMappingInfo info, RequestCondition<?> customRequestCondition) {
public RequestMappingInfo(RequestMappingInfo info, @Nullable RequestCondition<?> customRequestCondition) {
this(info.name, info.patternsCondition, info.methodsCondition, info.paramsCondition, info.headersCondition,
info.consumesCondition, info.producesCondition, customRequestCondition);
}

Loading…
Cancel
Save