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

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

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

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

@ -21,6 +21,7 @@ import java.util.Iterator;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.lang.Nullable;
/** /**
* Configuration interface to be implemented by most listable bean factories. * Configuration interface to be implemented by most listable bean factories.
@ -105,7 +106,7 @@ public interface ConfigurableListableBeanFactory
* @throws NoSuchBeanDefinitionException if there is no bean with the given name * @throws NoSuchBeanDefinitionException if there is no bean with the given name
* defined in this factory * 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. * 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
* @see ChildBeanDefinition * @see ChildBeanDefinition
* @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory#getBeanDefinition * @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). * 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;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.core.AliasRegistry; import org.springframework.core.AliasRegistry;
import org.springframework.lang.Nullable;
/** /**
* Interface for registries that hold bean definitions, for example RootBeanDefinition * Interface for registries that hold bean definitions, for example RootBeanDefinition
@ -74,7 +75,7 @@ public interface BeanDefinitionRegistry extends AliasRegistry {
* @return the BeanDefinition for the given name (never {@code null}) * @return the BeanDefinition for the given name (never {@code null})
* @throws NoSuchBeanDefinitionException if there is no such bean definition * @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. * 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
* Specify an id for serialization purposes, allowing this BeanFactory to be * Specify an id for serialization purposes, allowing this BeanFactory to be
* deserialized from this id back into the BeanFactory object, if needed. * 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) { if (serializationId != null) {
serializableFactories.put(serializationId, new WeakReference<>(this)); serializableFactories.put(serializationId, new WeakReference<>(this));
} }
@ -671,7 +671,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
} }
@Override @Override
public BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException { public BeanDefinition getBeanDefinition(@Nullable String beanName) throws NoSuchBeanDefinitionException {
BeanDefinition bd = this.beanDefinitionMap.get(beanName); BeanDefinition bd = this.beanDefinitionMap.get(beanName);
if (bd == null) { if (bd == null) {
if (this.logger.isTraceEnabled()) { 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 {
* @param beanClass the class of the bean to instantiate * @param beanClass the class of the bean to instantiate
* @see #setBeanClass * @see #setBeanClass
*/ */
public RootBeanDefinition(Class<?> beanClass) { public RootBeanDefinition(@Nullable Class<?> beanClass) {
super(); super();
setBeanClass(beanClass); setBeanClass(beanClass);
} }
@ -131,7 +131,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
* @since 5.0 * @since 5.0
* @see #setInstanceSupplier * @see #setInstanceSupplier
*/ */
public <T> RootBeanDefinition(Class<T> beanClass, Supplier<T> instanceSupplier) { public <T> RootBeanDefinition(@Nullable Class<T> beanClass, @Nullable Supplier<T> instanceSupplier) {
super(); super();
setBeanClass(beanClass); setBeanClass(beanClass);
setInstanceSupplier(instanceSupplier); setInstanceSupplier(instanceSupplier);
@ -147,7 +147,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
* @since 5.0 * @since 5.0
* @see #setInstanceSupplier * @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(); super();
setBeanClass(beanClass); setBeanClass(beanClass);
setScope(scope); setScope(scope);
@ -162,7 +162,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
* @param dependencyCheck whether to perform a dependency check for objects * @param dependencyCheck whether to perform a dependency check for objects
* (not applicable to autowiring a constructor, thus ignored there) * (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(); super();
setBeanClass(beanClass); setBeanClass(beanClass);
setAutowireMode(autowireMode); setAutowireMode(autowireMode);
@ -178,7 +178,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
* @param cargs the constructor argument values to apply * @param cargs the constructor argument values to apply
* @param pvs the property 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); super(cargs, pvs);
setBeanClass(beanClass); 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;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.core.SimpleAliasRegistry; import org.springframework.core.SimpleAliasRegistry;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -57,7 +58,7 @@ public class SimpleBeanDefinitionRegistry extends SimpleAliasRegistry implements
} }
@Override @Override
public BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException { public BeanDefinition getBeanDefinition(@Nullable String beanName) throws NoSuchBeanDefinitionException {
BeanDefinition bd = this.beanDefinitionMap.get(beanName); BeanDefinition bd = this.beanDefinitionMap.get(beanName);
if (bd == null) { if (bd == null) {
throw new NoSuchBeanDefinitionException(beanName); 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
} }
@Override @Override
public BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException { public BeanDefinition getBeanDefinition(@Nullable String beanName) throws NoSuchBeanDefinitionException {
return this.beanFactory.getBeanDefinition(beanName); 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 {
* @see AnnotatedElement#getAnnotations() * @see AnnotatedElement#getAnnotations()
*/ */
@Nullable @Nullable
public static Annotation[] getAnnotations(AnnotatedElement annotatedElement) { public static Annotation[] getAnnotations(@Nullable AnnotatedElement annotatedElement) {
try { try {
return synthesizeAnnotationArray(annotatedElement.getAnnotations(), annotatedElement); return synthesizeAnnotationArray(annotatedElement.getAnnotations(), annotatedElement);
} }
@ -1441,7 +1441,7 @@ public abstract class AnnotationUtils {
} }
@SuppressWarnings("unchecked") @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) { if (annotation == null) {
return null; return null;
} }
@ -1548,8 +1548,7 @@ public abstract class AnnotationUtils {
* @see #synthesizeAnnotation(Annotation, AnnotatedElement) * @see #synthesizeAnnotation(Annotation, AnnotatedElement)
* @see #synthesizeAnnotation(Map, Class, AnnotatedElement) * @see #synthesizeAnnotation(Map, Class, AnnotatedElement)
*/ */
@Nullable static Annotation[] synthesizeAnnotationArray(Annotation[] annotations, @Nullable Object annotatedElement) {
static Annotation[] synthesizeAnnotationArray(@Nullable Annotation[] annotations, @Nullable Object annotatedElement) {
if (annotations == null) { if (annotations == null) {
return 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 {
* Create a new resolver against the given property sources. * Create a new resolver against the given property sources.
* @param propertySources the set of {@link PropertySource} objects to use * @param propertySources the set of {@link PropertySource} objects to use
*/ */
public PropertySourcesPropertyResolver(PropertySources propertySources) { public PropertySourcesPropertyResolver(@Nullable PropertySources propertySources) {
this.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;
* *
* @author Sebastien Deleuze * @author Sebastien Deleuze
* @since 5.0 * @since 5.0
* @see NonNull
* @see javax.annotation.Nonnull * @see javax.annotation.Nonnull
*/ */
@Documented @Documented

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

@ -140,7 +140,8 @@ public abstract class ReflectionUtils {
* @param target the target object from which to get the field * @param target the target object from which to get the field
* @return the field's current value * @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 { try {
return field.get(target); return field.get(target);
} }

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

@ -978,7 +978,7 @@ public abstract class StringUtils {
* @param array the original {@code String} array * @param array the original {@code String} array
* @return the resulting array (of the same size) with trimmed elements * @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)) { if (ObjectUtils.isEmpty(array)) {
return new String[0]; 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;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.lang.Nullable;
/** /**
* Interface to provide configuration for a web application. This is read-only while * Interface to provide configuration for a web application. This is read-only while
@ -100,6 +101,7 @@ public interface WebApplicationContext extends ApplicationContext {
* Return the standard Servlet API ServletContext for this application. * Return the standard Servlet API ServletContext for this application.
* <p>Also available for a Portlet application, in addition to the PortletContext. * <p>Also available for a Portlet application, in addition to the PortletContext.
*/ */
@Nullable
ServletContext getServletContext(); ServletContext getServletContext();
} }

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

@ -16,6 +16,7 @@
package org.springframework.web.util; package org.springframework.web.util;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
@ -58,7 +59,7 @@ public abstract class HtmlUtils {
* @param input the (unescaped) input string * @param input the (unescaped) input string
* @return the escaped 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); return htmlEscape(input, WebUtils.DEFAULT_CHARACTER_ENCODING);
} }
@ -78,7 +79,7 @@ public abstract class HtmlUtils {
* @return the escaped string * @return the escaped string
* @since 4.1.2 * @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"); Assert.notNull(encoding, "Encoding is required");
if (input == null) { if (input == null) {
return null; return null;
@ -109,7 +110,7 @@ public abstract class HtmlUtils {
* @param input the (unescaped) input string * @param input the (unescaped) input string
* @return the escaped 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); return htmlEscapeDecimal(input, WebUtils.DEFAULT_CHARACTER_ENCODING);
} }
@ -129,7 +130,7 @@ public abstract class HtmlUtils {
* @return the escaped string * @return the escaped string
* @since 4.1.2 * @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"); Assert.notNull(encoding, "Encoding is required");
if (input == null) { if (input == null) {
return null; return null;
@ -161,7 +162,7 @@ public abstract class HtmlUtils {
* @param input the (unescaped) input string * @param input the (unescaped) input string
* @return the escaped 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); return htmlEscapeHex(input, WebUtils.DEFAULT_CHARACTER_ENCODING);
} }
@ -181,7 +182,7 @@ public abstract class HtmlUtils {
* @return the escaped string * @return the escaped string
* @since 4.1.2 * @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"); Assert.notNull(encoding, "Encoding is required");
if (input == null) { if (input == null) {
return null; return null;
@ -220,7 +221,7 @@ public abstract class HtmlUtils {
* @param input the (escaped) input string * @param input the (escaped) input string
* @return the unescaped string * @return the unescaped string
*/ */
public static String htmlUnescape(String input) { public static String htmlUnescape(@Nullable String input) {
if (input == null) { if (input == null) {
return 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
private final RequestConditionHolder customConditionHolder; private final RequestConditionHolder customConditionHolder;
public RequestMappingInfo(String name, PatternsRequestCondition patterns, RequestMethodsRequestCondition methods, public RequestMappingInfo(@Nullable String name, @Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods,
ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes, @Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
ProducesRequestCondition produces, RequestCondition<?> custom) { @Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {
this.name = (StringUtils.hasText(name) ? name : null); this.name = (StringUtils.hasText(name) ? name : null);
this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition()); this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition());
@ -86,9 +86,9 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
/** /**
* Creates a new instance with the given request conditions. * Creates a new instance with the given request conditions.
*/ */
public RequestMappingInfo(PatternsRequestCondition patterns, RequestMethodsRequestCondition methods, public RequestMappingInfo(@Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods,
ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes, @Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
ProducesRequestCondition produces, RequestCondition<?> custom) { @Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {
this(null, patterns, methods, params, headers, consumes, produces, custom); this(null, patterns, methods, params, headers, consumes, produces, custom);
} }
@ -96,7 +96,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
/** /**
* Re-create a RequestMappingInfo with the given custom request condition. * 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, this(info.name, info.patternsCondition, info.methodsCondition, info.paramsCondition, info.headersCondition,
info.consumesCondition, info.producesCondition, customRequestCondition); info.consumesCondition, info.producesCondition, customRequestCondition);
} }

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

@ -54,7 +54,7 @@ public class HandlerExecutionChain {
* Create a new HandlerExecutionChain. * Create a new HandlerExecutionChain.
* @param handler the handler object to execute * @param handler the handler object to execute
*/ */
public HandlerExecutionChain(Object handler) { public HandlerExecutionChain(@Nullable Object handler) {
this(handler, (HandlerInterceptor[]) null); this(handler, (HandlerInterceptor[]) null);
} }
@ -64,7 +64,7 @@ public class HandlerExecutionChain {
* @param interceptors the array of interceptors to apply * @param interceptors the array of interceptors to apply
* (in the given order) before the handler itself executes * (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) { if (handler instanceof HandlerExecutionChain) {
HandlerExecutionChain originalChain = (HandlerExecutionChain) handler; HandlerExecutionChain originalChain = (HandlerExecutionChain) handler;
this.handler = originalChain.getHandler(); 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
private final RequestConditionHolder customConditionHolder; private final RequestConditionHolder customConditionHolder;
public RequestMappingInfo(String name, PatternsRequestCondition patterns, RequestMethodsRequestCondition methods, public RequestMappingInfo(@Nullable String name, @Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods,
ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes, @Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
ProducesRequestCondition produces, RequestCondition<?> custom) { @Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {
this.name = (StringUtils.hasText(name) ? name : null); this.name = (StringUtils.hasText(name) ? name : null);
this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition()); this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition());
@ -88,9 +88,9 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
/** /**
* Creates a new instance with the given request conditions. * Creates a new instance with the given request conditions.
*/ */
public RequestMappingInfo(PatternsRequestCondition patterns, RequestMethodsRequestCondition methods, public RequestMappingInfo(@Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods,
ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes, @Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
ProducesRequestCondition produces, RequestCondition<?> custom) { @Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {
this(null, patterns, methods, params, headers, consumes, produces, custom); this(null, patterns, methods, params, headers, consumes, produces, custom);
} }
@ -98,7 +98,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
/** /**
* Re-create a RequestMappingInfo with the given custom request condition. * 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, this(info.name, info.patternsCondition, info.methodsCondition, info.paramsCondition, info.headersCondition,
info.consumesCondition, info.producesCondition, customRequestCondition); info.consumesCondition, info.producesCondition, customRequestCondition);
} }

Loading…
Cancel
Save