Add missing @Nullable annotations on parameters

Issue: SPR-15540
This commit is contained in:
Sebastien Deleuze 2017-05-31 12:37:54 +02:00
parent ad2c0f8410
commit b47d713e14
380 changed files with 1085 additions and 732 deletions

View File

@ -19,6 +19,8 @@ package org.springframework.aop;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.springframework.lang.Nullable;
/** /**
* Canonical MethodMatcher instance that matches all methods. * Canonical MethodMatcher instance that matches all methods.
* *
@ -43,12 +45,12 @@ class TrueMethodMatcher implements MethodMatcher, Serializable {
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
return true; return true;
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass, Object... args) { public boolean matches(Method method, @Nullable Class<?> targetClass, Object... args) {
// Should never be invoked as isRuntime returns false. // Should never be invoked as isRuntime returns false.
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -698,7 +698,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
return !this.adviceMethod.equals(method); return !this.adviceMethod.equals(method);
} }

View File

@ -61,7 +61,7 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice
} }
@Override @Override
public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable { public void afterReturning(@Nullable Object returnValue, Method method, Object[] args, @Nullable Object target) throws Throwable {
if (shouldInvokeOnReturnValueOf(method, returnValue)) { if (shouldInvokeOnReturnValueOf(method, returnValue)) {
invokeAdviceMethod(getJoinPointMatch(), returnValue, null); invokeAdviceMethod(getJoinPointMatch(), returnValue, null);
} }

View File

@ -277,7 +277,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass, boolean beanHasIntroductions) { public boolean matches(Method method, @Nullable Class<?> targetClass, boolean beanHasIntroductions) {
checkReadyToMatch(); checkReadyToMatch();
Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass); Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
ShadowMatch shadowMatch = getShadowMatch(targetMethod, method); ShadowMatch shadowMatch = getShadowMatch(targetMethod, method);
@ -306,7 +306,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
return matches(method, targetClass, false); return matches(method, targetClass, false);
} }
@ -317,7 +317,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass, Object... args) { public boolean matches(Method method, @Nullable Class<?> targetClass, Object... args) {
checkReadyToMatch(); checkReadyToMatch();
ShadowMatch shadowMatch = getShadowMatch(AopUtils.getMostSpecificMethod(method, targetClass), method); ShadowMatch shadowMatch = getShadowMatch(AopUtils.getMostSpecificMethod(method, targetClass), method);
ShadowMatch originalShadowMatch = getShadowMatch(method, method); ShadowMatch originalShadowMatch = getShadowMatch(method, method);

View File

@ -20,6 +20,7 @@ import java.io.Serializable;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.springframework.aop.MethodBeforeAdvice; import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.lang.Nullable;
/** /**
* Spring AOP advice that wraps an AspectJ before method. * Spring AOP advice that wraps an AspectJ before method.
@ -39,7 +40,7 @@ public class AspectJMethodBeforeAdvice extends AbstractAspectJAdvice implements
@Override @Override
public void before(Method method, Object[] args, Object target) throws Throwable { public void before(Method method, Object[] args, @Nullable Object target) throws Throwable {
invokeAdviceMethod(getJoinPointMatch(), null, null); invokeAdviceMethod(getJoinPointMatch(), null, null);
} }

View File

@ -31,6 +31,7 @@ import org.springframework.aop.aspectj.InstantiationModelAwarePointcutAdvisor;
import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.AspectJAnnotation; import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.AspectJAnnotation;
import org.springframework.aop.support.DynamicMethodMatcherPointcut; import org.springframework.aop.support.DynamicMethodMatcherPointcut;
import org.springframework.aop.support.Pointcuts; import org.springframework.aop.support.Pointcuts;
import org.springframework.lang.Nullable;
/** /**
* Internal implementation of AspectJPointcutAdvisor. * Internal implementation of AspectJPointcutAdvisor.
@ -274,14 +275,14 @@ class InstantiationModelAwarePointcutAdvisorImpl
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
// We're either instantiated and matching on declared pointcut, or uninstantiated matching on either pointcut // We're either instantiated and matching on declared pointcut, or uninstantiated matching on either pointcut
return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass)) || return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass)) ||
this.preInstantiationPointcut.getMethodMatcher().matches(method, targetClass); this.preInstantiationPointcut.getMethodMatcher().matches(method, targetClass);
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass, Object... args) { public boolean matches(Method method, @Nullable Class<?> targetClass, Object... args) {
// This can match only on declared pointcut. // This can match only on declared pointcut.
return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass)); return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass));
} }

View File

@ -315,7 +315,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
public SyntheticInstantiationAdvisor(final MetadataAwareAspectInstanceFactory aif) { public SyntheticInstantiationAdvisor(final MetadataAwareAspectInstanceFactory aif) {
super(aif.getAspectMetadata().getPerClausePointcut(), new MethodBeforeAdvice() { super(aif.getAspectMetadata().getPerClausePointcut(), new MethodBeforeAdvice() {
@Override @Override
public void before(Method method, Object[] args, Object target) { public void before(Method method, Object[] args, @Nullable Object target) {
// Simply instantiate the aspect // Simply instantiate the aspect
aif.getAspectInstance(); aif.getAspectInstance();
} }

View File

@ -24,6 +24,7 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.FactoryBeanNotInitializedException; import org.springframework.beans.factory.FactoryBeanNotInitializedException;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
/** /**
@ -123,7 +124,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
if (this.proxyClassLoader == null) { if (this.proxyClassLoader == null) {
this.proxyClassLoader = classLoader; this.proxyClassLoader = classLoader;
} }

View File

@ -153,7 +153,7 @@ class CglibAopProxy implements AopProxy, Serializable {
} }
@Override @Override
public Object getProxy(ClassLoader classLoader) { public Object getProxy(@Nullable ClassLoader classLoader) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Creating CGLIB proxy: target source is " + this.advised.getTargetSource()); logger.debug("Creating CGLIB proxy: target source is " + this.advised.getTargetSource());
} }

View File

@ -32,6 +32,7 @@ import org.springframework.aop.PointcutAdvisor;
import org.springframework.aop.framework.adapter.AdvisorAdapterRegistry; import org.springframework.aop.framework.adapter.AdvisorAdapterRegistry;
import org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry; import org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry;
import org.springframework.aop.support.MethodMatchers; import org.springframework.aop.support.MethodMatchers;
import org.springframework.lang.Nullable;
/** /**
* A simple but definitive way of working out an advice chain for a Method, * A simple but definitive way of working out an advice chain for a Method,
@ -48,7 +49,7 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
@Override @Override
public List<Object> getInterceptorsAndDynamicInterceptionAdvice( public List<Object> getInterceptorsAndDynamicInterceptionAdvice(
Advised config, Method method, Class<?> targetClass) { Advised config, Method method, @Nullable Class<?> targetClass) {
// This is somewhat tricky... We have to process introductions first, // This is somewhat tricky... We have to process introductions first,
// but we need to preserve order in the ultimate list. // but we need to preserve order in the ultimate list.

View File

@ -31,6 +31,7 @@ import org.springframework.aop.RawTargetAccess;
import org.springframework.aop.TargetSource; import org.springframework.aop.TargetSource;
import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.AopUtils;
import org.springframework.core.DecoratingProxy; import org.springframework.core.DecoratingProxy;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -113,7 +114,7 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
} }
@Override @Override
public Object getProxy(ClassLoader classLoader) { public Object getProxy(@Nullable ClassLoader classLoader) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Creating JDK dynamic proxy: target source is " + this.advised.getTargetSource()); logger.debug("Creating JDK dynamic proxy: target source is " + this.advised.getTargetSource());
} }

View File

@ -45,6 +45,7 @@ import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.FactoryBeanNotInitializedException; import org.springframework.beans.factory.FactoryBeanNotInitializedException;
import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
@ -213,13 +214,13 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
* containing BeanFactory for loading all bean classes. This can be * containing BeanFactory for loading all bean classes. This can be
* overridden here for specific proxies. * overridden here for specific proxies.
*/ */
public void setProxyClassLoader(ClassLoader classLoader) { public void setProxyClassLoader(@Nullable ClassLoader classLoader) {
this.proxyClassLoader = classLoader; this.proxyClassLoader = classLoader;
this.classLoaderConfigured = (classLoader != null); this.classLoaderConfigured = (classLoader != null);
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
if (!this.classLoaderConfigured) { if (!this.classLoaderConfigured) {
this.proxyClassLoader = classLoader; this.proxyClassLoader = classLoader;
} }

View File

@ -21,6 +21,7 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
@ -81,7 +82,7 @@ public class ProxyProcessorSupport extends ProxyConfig implements Ordered, BeanC
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
if (!this.classLoaderConfigured) { if (!this.classLoaderConfigured) {
this.proxyClassLoader = classLoader; this.proxyClassLoader = classLoader;
} }

View File

@ -28,6 +28,7 @@ import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.ProxyMethodInvocation; import org.springframework.aop.ProxyMethodInvocation;
import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.AopUtils;
import org.springframework.core.BridgeMethodResolver; import org.springframework.core.BridgeMethodResolver;
import org.springframework.lang.Nullable;
/** /**
* Spring's implementation of the AOP Alliance * Spring's implementation of the AOP Alliance
@ -240,7 +241,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
@Override @Override
public void setUserAttribute(String key, Object value) { public void setUserAttribute(String key, @Nullable Object value) {
if (value != null) { if (value != null) {
if (this.userAttributes == null) { if (this.userAttributes == null) {
this.userAttributes = new HashMap<>(); this.userAttributes = new HashMap<>();

View File

@ -24,6 +24,7 @@ import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.lang.Nullable;
/** /**
* Generic auto proxy creator that builds AOP proxies for specific beans * Generic auto proxy creator that builds AOP proxies for specific beans
@ -66,7 +67,8 @@ public abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyC
@Override @Override
protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, TargetSource targetSource) { @Nullable
protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, @Nullable TargetSource targetSource) {
List<Advisor> advisors = findEligibleAdvisors(beanClass, beanName); List<Advisor> advisors = findEligibleAdvisors(beanClass, beanName);
if (advisors.isEmpty()) { if (advisors.isEmpty()) {
return DO_NOT_PROXY; return DO_NOT_PROXY;

View File

@ -22,6 +22,7 @@ import java.util.List;
import org.springframework.aop.TargetSource; import org.springframework.aop.TargetSource;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.FactoryBean;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.PatternMatchUtils; import org.springframework.util.PatternMatchUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -73,7 +74,8 @@ public class BeanNameAutoProxyCreator extends AbstractAutoProxyCreator {
* Identify as bean to proxy if the bean name is in the configured list of names. * Identify as bean to proxy if the bean name is in the configured list of names.
*/ */
@Override @Override
protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, TargetSource targetSource) { @Nullable
protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, @Nullable TargetSource targetSource) {
if (this.beanNames != null) { if (this.beanNames != null) {
for (String mappedName : this.beanNames) { for (String mappedName : this.beanNames) {
if (FactoryBean.class.isAssignableFrom(beanClass)) { if (FactoryBean.class.isAssignableFrom(beanClass)) {

View File

@ -20,6 +20,7 @@ import java.io.Serializable;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Arrays; import java.util.Arrays;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
@ -129,7 +130,7 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo
* plus the name of the method. * plus the name of the method.
*/ */
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
return ((targetClass != null && matchesPattern(ClassUtils.getQualifiedMethodName(method, targetClass))) || return ((targetClass != null && matchesPattern(ClassUtils.getQualifiedMethodName(method, targetClass))) ||
matchesPattern(ClassUtils.getQualifiedMethodName(method))); matchesPattern(ClassUtils.getQualifiedMethodName(method)));
} }

View File

@ -80,7 +80,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
* some candidate classes. * some candidate classes.
*/ */
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
return true; return true;
} }
@ -90,7 +90,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass, Object... args) { public boolean matches(Method method, @Nullable Class<?> targetClass, Object... args) {
this.evaluations++; this.evaluations++;
for (StackTraceElement element : new Throwable().getStackTrace()) { for (StackTraceElement element : new Throwable().getStackTrace()) {

View File

@ -19,6 +19,7 @@ package org.springframework.aop.support;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.springframework.aop.MethodMatcher; import org.springframework.aop.MethodMatcher;
import org.springframework.lang.Nullable;
/** /**
* Convenient abstract superclass for dynamic method matchers, * Convenient abstract superclass for dynamic method matchers,
@ -36,7 +37,7 @@ public abstract class DynamicMethodMatcher implements MethodMatcher {
* always returns true. * always returns true.
*/ */
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
return true; return true;
} }

View File

@ -114,13 +114,13 @@ public abstract class MethodMatchers {
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass, boolean hasIntroductions) { public boolean matches(Method method, @Nullable Class<?> targetClass, boolean hasIntroductions) {
return (matchesClass1(targetClass) && MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions)) || return (matchesClass1(targetClass) && MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions)) ||
(matchesClass2(targetClass) && MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions)); (matchesClass2(targetClass) && MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions));
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
return (matchesClass1(targetClass) && this.mm1.matches(method, targetClass)) || return (matchesClass1(targetClass) && this.mm1.matches(method, targetClass)) ||
(matchesClass2(targetClass) && this.mm2.matches(method, targetClass)); (matchesClass2(targetClass) && this.mm2.matches(method, targetClass));
} }
@ -139,7 +139,7 @@ public abstract class MethodMatchers {
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass, Object... args) { public boolean matches(Method method, @Nullable Class<?> targetClass, Object... args) {
return this.mm1.matches(method, targetClass, args) || this.mm2.matches(method, targetClass, args); return this.mm1.matches(method, targetClass, args) || this.mm2.matches(method, targetClass, args);
} }
@ -230,13 +230,13 @@ public abstract class MethodMatchers {
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass, boolean hasIntroductions) { public boolean matches(Method method, @Nullable Class<?> targetClass, boolean hasIntroductions) {
return MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) && return MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) &&
MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions); MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions);
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
return this.mm1.matches(method, targetClass) && this.mm2.matches(method, targetClass); return this.mm1.matches(method, targetClass) && this.mm2.matches(method, targetClass);
} }
@ -246,7 +246,7 @@ public abstract class MethodMatchers {
} }
@Override @Override
public boolean matches(Method method, Class<?> targetClass, Object... args) { public boolean matches(Method method, @Nullable Class<?> targetClass, Object... args) {
// Because a dynamic intersection may be composed of a static and dynamic part, // Because a dynamic intersection may be composed of a static and dynamic part,
// we must avoid calling the 3-arg matches method on a dynamic matcher, as // we must avoid calling the 3-arg matches method on a dynamic matcher, as
// it will probably be an unsupported operation. // it will probably be an unsupported operation.

View File

@ -22,6 +22,7 @@ import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.PatternMatchUtils; import org.springframework.util.PatternMatchUtils;
@ -78,7 +79,7 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
for (String mappedName : this.mappedNames) { for (String mappedName : this.mappedNames) {
if (mappedName.equals(method.getName()) || isMatch(method.getName(), mappedName)) { if (mappedName.equals(method.getName()) || isMatch(method.getName(), mappedName)) {
return true; return true;

View File

@ -21,6 +21,7 @@ import java.lang.reflect.Method;
import org.springframework.aop.MethodMatcher; import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut; import org.springframework.aop.Pointcut;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
@ -97,7 +98,7 @@ public abstract class Pointcuts {
public static SetterPointcut INSTANCE = new SetterPointcut(); public static SetterPointcut INSTANCE = new SetterPointcut();
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
return (method.getName().startsWith("set") && return (method.getName().startsWith("set") &&
method.getParameterCount() == 1 && method.getParameterCount() == 1 &&
method.getReturnType() == Void.TYPE); method.getReturnType() == Void.TYPE);
@ -118,7 +119,7 @@ public abstract class Pointcuts {
public static GetterPointcut INSTANCE = new GetterPointcut(); public static GetterPointcut INSTANCE = new GetterPointcut();
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
return (method.getName().startsWith("get") && return (method.getName().startsWith("get") &&
method.getParameterCount() == 0); method.getParameterCount() == 0);
} }

View File

@ -19,6 +19,7 @@ package org.springframework.aop.support;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.springframework.aop.MethodMatcher; import org.springframework.aop.MethodMatcher;
import org.springframework.lang.Nullable;
/** /**
* Convenient abstract superclass for static method matchers, which don't care * Convenient abstract superclass for static method matchers, which don't care
@ -32,7 +33,7 @@ public abstract class StaticMethodMatcher implements MethodMatcher {
} }
@Override @Override
public final boolean matches(Method method, Class<?> targetClass, Object... args) { public final boolean matches(Method method, @Nullable Class<?> targetClass, Object... args) {
// should never be invoked because isRuntime() returns false // should never be invoked because isRuntime() returns false
throw new UnsupportedOperationException("Illegal MethodMatcher usage"); throw new UnsupportedOperationException("Illegal MethodMatcher usage");
} }

View File

@ -22,6 +22,7 @@ import java.lang.reflect.Method;
import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.AopUtils;
import org.springframework.aop.support.StaticMethodMatcher; import org.springframework.aop.support.StaticMethodMatcher;
import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
@ -66,7 +67,7 @@ public class AnnotationMethodMatcher extends StaticMethodMatcher {
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
if (matchesMethod(method)) { if (matchesMethod(method)) {
return true; return true;
} }

View File

@ -33,6 +33,7 @@ import org.springframework.aop.framework.AopContext;
import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.AopUtils;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
@ -81,7 +82,7 @@ public class MethodInvocationProceedingJoinPointTests {
private int depth; private int depth;
@Override @Override
public void before(Method method, Object[] args, Object target) throws Throwable { public void before(Method method, Object[] args, @Nullable Object target) throws Throwable {
JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint(); JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint();
assertTrue("Method named in toString", jp.toString().contains(method.getName())); assertTrue("Method named in toString", jp.toString().contains(method.getName()));
// Ensure that these don't cause problems // Ensure that these don't cause problems
@ -138,7 +139,7 @@ public class MethodInvocationProceedingJoinPointTests {
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR); pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
pf.addAdvice(new MethodBeforeAdvice() { pf.addAdvice(new MethodBeforeAdvice() {
@Override @Override
public void before(Method method, Object[] args, Object target) throws Throwable { public void before(Method method, Object[] args, @Nullable Object target) throws Throwable {
SourceLocation sloc = AbstractAspectJAdvice.currentJoinPoint().getSourceLocation(); SourceLocation sloc = AbstractAspectJAdvice.currentJoinPoint().getSourceLocation();
assertEquals("Same source location must be returned on subsequent requests", sloc, AbstractAspectJAdvice.currentJoinPoint().getSourceLocation()); assertEquals("Same source location must be returned on subsequent requests", sloc, AbstractAspectJAdvice.currentJoinPoint().getSourceLocation());
assertEquals(TestBean.class, sloc.getWithinType()); assertEquals(TestBean.class, sloc.getWithinType());
@ -171,7 +172,7 @@ public class MethodInvocationProceedingJoinPointTests {
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR); pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
pf.addAdvice(new MethodBeforeAdvice() { pf.addAdvice(new MethodBeforeAdvice() {
@Override @Override
public void before(Method method, Object[] args, Object target) throws Throwable { public void before(Method method, Object[] args, @Nullable Object target) throws Throwable {
StaticPart staticPart = AbstractAspectJAdvice.currentJoinPoint().getStaticPart(); StaticPart staticPart = AbstractAspectJAdvice.currentJoinPoint().getStaticPart();
assertEquals("Same static part must be returned on subsequent requests", staticPart, AbstractAspectJAdvice.currentJoinPoint().getStaticPart()); assertEquals("Same static part must be returned on subsequent requests", staticPart, AbstractAspectJAdvice.currentJoinPoint().getStaticPart());
assertEquals(ProceedingJoinPoint.METHOD_EXECUTION, staticPart.getKind()); assertEquals(ProceedingJoinPoint.METHOD_EXECUTION, staticPart.getKind());
@ -191,7 +192,7 @@ public class MethodInvocationProceedingJoinPointTests {
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR); pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
pf.addAdvice(new MethodBeforeAdvice() { pf.addAdvice(new MethodBeforeAdvice() {
@Override @Override
public void before(Method method, Object[] args, Object target) throws Throwable { public void before(Method method, Object[] args, @Nullable Object target) throws Throwable {
// makeEncSJP, although meant for computing the enclosing join point, // makeEncSJP, although meant for computing the enclosing join point,
// it serves our purpose here // it serves our purpose here
JoinPoint.StaticPart aspectJVersionJp = Factory.makeEncSJP(method); JoinPoint.StaticPart aspectJVersionJp = Factory.makeEncSJP(method);

View File

@ -32,6 +32,7 @@ import org.springframework.aop.ThrowsAdvice;
import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.core.OverridingClassLoader; import org.springframework.core.OverridingClassLoader;
import org.springframework.lang.Nullable;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -174,7 +175,7 @@ public class TrickyAspectJPointcutExpressionTests {
private int countThrows = 0; private int countThrows = 0;
@Override @Override
public void before(Method method, Object[] objects, Object o) throws Throwable { public void before(Method method, Object[] objects, @Nullable Object o) throws Throwable {
countBefore++; countBefore++;
} }

View File

@ -33,6 +33,7 @@ import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.aspectj.AspectJMethodBeforeAdvice; import org.springframework.aop.aspectj.AspectJMethodBeforeAdvice;
import org.springframework.aop.aspectj.AspectJPointcutAdvisor; import org.springframework.aop.aspectj.AspectJPointcutAdvisor;
import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.lang.Nullable;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -196,7 +197,7 @@ public class AspectJPrecedenceComparatorTests {
private Advisor createSpringAOPAfterAdvice(int order) { private Advisor createSpringAOPAfterAdvice(int order) {
AfterReturningAdvice advice = new AfterReturningAdvice() { AfterReturningAdvice advice = new AfterReturningAdvice() {
@Override @Override
public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable { public void afterReturning(@Nullable Object returnValue, Method method, Object[] args, @Nullable Object target) throws Throwable {
} }
}; };
DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(this.anyOldPointcut, advice); DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(this.anyOldPointcut, advice);

View File

@ -25,6 +25,7 @@ import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut; import org.springframework.aop.Pointcut;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.target.EmptyTargetSource; import org.springframework.aop.target.EmptyTargetSource;
import org.springframework.lang.Nullable;
import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.sample.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils; import org.springframework.util.SerializationTestUtils;
@ -41,7 +42,7 @@ public class AopUtilsTests {
public void testPointcutCanNeverApply() { public void testPointcutCanNeverApply() {
class TestPointcut extends StaticMethodMatcherPointcut { class TestPointcut extends StaticMethodMatcherPointcut {
@Override @Override
public boolean matches(Method method, Class<?> clazzy) { public boolean matches(Method method, @Nullable Class<?> clazzy) {
return false; return false;
} }
} }
@ -60,7 +61,7 @@ public class AopUtilsTests {
public void testPointcutAppliesToOneMethodOnObject() { public void testPointcutAppliesToOneMethodOnObject() {
class TestPointcut extends StaticMethodMatcherPointcut { class TestPointcut extends StaticMethodMatcherPointcut {
@Override @Override
public boolean matches(Method method, Class<?> clazz) { public boolean matches(Method method, @Nullable Class<?> clazz) {
return method.getName().equals("hashCode"); return method.getName().equals("hashCode");
} }
} }

View File

@ -24,6 +24,7 @@ import org.springframework.aop.ClassFilter;
import org.springframework.aop.MethodMatcher; import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut; import org.springframework.aop.Pointcut;
import org.springframework.core.NestedRuntimeException; import org.springframework.core.NestedRuntimeException;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -36,28 +37,28 @@ public class ComposablePointcutTests {
public static MethodMatcher GETTER_METHOD_MATCHER = new StaticMethodMatcher() { public static MethodMatcher GETTER_METHOD_MATCHER = new StaticMethodMatcher() {
@Override @Override
public boolean matches(Method m, Class<?> targetClass) { public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getName().startsWith("get"); return m.getName().startsWith("get");
} }
}; };
public static MethodMatcher GET_AGE_METHOD_MATCHER = new StaticMethodMatcher() { public static MethodMatcher GET_AGE_METHOD_MATCHER = new StaticMethodMatcher() {
@Override @Override
public boolean matches(Method m, Class<?> targetClass) { public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getName().equals("getAge"); return m.getName().equals("getAge");
} }
}; };
public static MethodMatcher ABSQUATULATE_METHOD_MATCHER = new StaticMethodMatcher() { public static MethodMatcher ABSQUATULATE_METHOD_MATCHER = new StaticMethodMatcher() {
@Override @Override
public boolean matches(Method m, Class<?> targetClass) { public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getName().equals("absquatulate"); return m.getName().equals("absquatulate");
} }
}; };
public static MethodMatcher SETTER_METHOD_MATCHER = new StaticMethodMatcher() { public static MethodMatcher SETTER_METHOD_MATCHER = new StaticMethodMatcher() {
@Override @Override
public boolean matches(Method m, Class<?> targetClass) { public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getName().startsWith("set"); return m.getName().startsWith("set");
} }
}; };

View File

@ -21,6 +21,7 @@ import java.lang.reflect.Method;
import org.junit.Test; import org.junit.Test;
import org.springframework.aop.MethodMatcher; import org.springframework.aop.MethodMatcher;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.IOther; import org.springframework.tests.sample.beans.IOther;
import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
@ -120,7 +121,7 @@ public class MethodMatchersTests {
} }
@Override @Override
public boolean matches(Method m, Class<?> targetClass) { public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getName().startsWith(prefix); return m.getName().startsWith(prefix);
} }
} }
@ -129,7 +130,7 @@ public class MethodMatchersTests {
private static class TestDynamicMethodMatcherWhichMatches extends DynamicMethodMatcher { private static class TestDynamicMethodMatcherWhichMatches extends DynamicMethodMatcher {
@Override @Override
public boolean matches(Method m, Class<?> targetClass, Object... args) { public boolean matches(Method m, @Nullable Class<?> targetClass, Object... args) {
return true; return true;
} }
} }
@ -138,7 +139,7 @@ public class MethodMatchersTests {
private static class TestDynamicMethodMatcherWhichDoesNotMatch extends DynamicMethodMatcher { private static class TestDynamicMethodMatcherWhichDoesNotMatch extends DynamicMethodMatcher {
@Override @Override
public boolean matches(Method m, Class<?> targetClass, Object... args) { public boolean matches(Method m, @Nullable Class<?> targetClass, Object... args) {
return false; return false;
} }
} }

View File

@ -22,6 +22,7 @@ import org.junit.Test;
import org.springframework.aop.ClassFilter; import org.springframework.aop.ClassFilter;
import org.springframework.aop.Pointcut; import org.springframework.aop.Pointcut;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -64,7 +65,7 @@ public class PointcutsTests {
} }
@Override @Override
public boolean matches(Method m, Class<?> targetClass) { public boolean matches(Method m, @Nullable Class<?> targetClass) {
return true; return true;
} }
}; };
@ -82,7 +83,7 @@ public class PointcutsTests {
} }
@Override @Override
public boolean matches(Method m, Class<?> targetClass) { public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getName().startsWith("set"); return m.getName().startsWith("set");
} }
}; };
@ -95,7 +96,7 @@ public class PointcutsTests {
} }
@Override @Override
public boolean matches(Method m, Class<?> targetClass) { public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getName().startsWith("get"); return m.getName().startsWith("get");
} }
}; };
@ -111,7 +112,7 @@ public class PointcutsTests {
} }
@Override @Override
public boolean matches(Method m, Class<?> targetClass) { public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getName().startsWith("get"); return m.getName().startsWith("get");
} }
}; };

View File

@ -67,7 +67,7 @@ public class BeanMetadataAttributeAccessor extends AttributeAccessorSupport impl
} }
@Override @Override
public void setAttribute(String name, Object value) { public void setAttribute(String name, @Nullable Object value) {
super.setAttribute(name, new BeanMetadataAttribute(name, value)); super.setAttribute(name, new BeanMetadataAttribute(name, value));
} }

View File

@ -284,7 +284,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
} }
@Override @Override
public void registerCustomEditor(Class<?> requiredType, String propertyPath, PropertyEditor propertyEditor) { public void registerCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath, PropertyEditor propertyEditor) {
if (requiredType == null && propertyPath == null) { if (requiredType == null && propertyPath == null) {
throw new IllegalArgumentException("Either requiredType or propertyPath is required"); throw new IllegalArgumentException("Either requiredType or propertyPath is required");
} }
@ -304,7 +304,8 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
} }
@Override @Override
public PropertyEditor findCustomEditor(Class<?> requiredType, String propertyPath) { @Nullable
public PropertyEditor findCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath) {
Class<?> requiredTypeToUse = requiredType; Class<?> requiredTypeToUse = requiredType;
if (propertyPath != null) { if (propertyPath != null) {
if (this.customEditorsForPath != null) { if (this.customEditorsForPath != null) {

View File

@ -21,6 +21,7 @@ import java.lang.reflect.Field;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
import org.springframework.core.convert.ConversionException; import org.springframework.core.convert.ConversionException;
import org.springframework.core.convert.ConverterNotFoundException; import org.springframework.core.convert.ConverterNotFoundException;
import org.springframework.lang.Nullable;
/** /**
* Base implementation of the {@link TypeConverter} interface, using a package-private delegate. * Base implementation of the {@link TypeConverter} interface, using a package-private delegate.
@ -36,25 +37,25 @@ public abstract class TypeConverterSupport extends PropertyEditorRegistrySupport
@Override @Override
public <T> T convertIfNecessary(Object value, Class<T> requiredType) throws TypeMismatchException { public <T> T convertIfNecessary(Object value, @Nullable Class<T> requiredType) throws TypeMismatchException {
return doConvert(value, requiredType, null, null); return doConvert(value, requiredType, null, null);
} }
@Override @Override
public <T> T convertIfNecessary(Object value, Class<T> requiredType, MethodParameter methodParam) public <T> T convertIfNecessary(Object value, @Nullable Class<T> requiredType, @Nullable MethodParameter methodParam)
throws TypeMismatchException { throws TypeMismatchException {
return doConvert(value, requiredType, methodParam, null); return doConvert(value, requiredType, methodParam, null);
} }
@Override @Override
public <T> T convertIfNecessary(Object value, Class<T> requiredType, Field field) public <T> T convertIfNecessary(Object value, @Nullable Class<T> requiredType, @Nullable Field field)
throws TypeMismatchException { throws TypeMismatchException {
return doConvert(value, requiredType, null, field); return doConvert(value, requiredType, null, field);
} }
private <T> T doConvert(Object value, Class<T> requiredType, MethodParameter methodParam, Field field) private <T> T doConvert(Object value, Class<T> requiredType, @Nullable MethodParameter methodParam, @Nullable Field field)
throws TypeMismatchException { throws TypeMismatchException {
try { try {
if (field != null) { if (field != null) {

View File

@ -25,6 +25,7 @@ import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
/** /**
@ -65,7 +66,7 @@ public class CustomAutowireConfigurer implements BeanFactoryPostProcessor, BeanC
} }
@Override @Override
public void setBeanClassLoader(ClassLoader beanClassLoader) { public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
this.beanClassLoader = beanClassLoader; this.beanClassLoader = beanClassLoader;
} }

View File

@ -91,7 +91,7 @@ public abstract class AbstractFactoryBean<T>
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.beanClassLoader = classLoader; this.beanClassLoader = classLoader;
} }

View File

@ -23,6 +23,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -86,7 +87,7 @@ public class CustomScopeConfigurer implements BeanFactoryPostProcessor, BeanClas
} }
@Override @Override
public void setBeanClassLoader(ClassLoader beanClassLoader) { public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
this.beanClassLoader = beanClassLoader; this.beanClassLoader = beanClassLoader;
} }

View File

@ -16,6 +16,7 @@
package org.springframework.beans.factory.config; package org.springframework.beans.factory.config;
import org.springframework.lang.Nullable;
import org.springframework.util.StringValueResolver; import org.springframework.util.StringValueResolver;
/** /**
@ -47,7 +48,7 @@ public class EmbeddedValueResolver implements StringValueResolver {
@Override @Override
public String resolveStringValue(String strVal) { public String resolveStringValue(@Nullable String strVal) {
String value = this.exprContext.getBeanFactory().resolveEmbeddedValue(strVal); String value = this.exprContext.getBeanFactory().resolveEmbeddedValue(strVal);
if (this.exprResolver != null && value != null) { if (this.exprResolver != null && value != null) {
Object evaluated = this.exprResolver.evaluate(value, this.exprContext); Object evaluated = this.exprResolver.evaluate(value, this.exprContext);

View File

@ -24,6 +24,7 @@ import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.FactoryBeanNotInitializedException; import org.springframework.beans.factory.FactoryBeanNotInitializedException;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -148,7 +149,7 @@ public class FieldRetrievingFactoryBean
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.beanClassLoader = classLoader; this.beanClassLoader = classLoader;
} }

View File

@ -24,6 +24,7 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.support.ArgumentConvertingMethodInvoker; import org.springframework.beans.support.ArgumentConvertingMethodInvoker;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
/** /**
@ -72,7 +73,7 @@ public class MethodInvokingBean extends ArgumentConvertingMethodInvoker
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.beanClassLoader = classLoader; this.beanClassLoader = classLoader;
} }

View File

@ -238,7 +238,8 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
} }
@Override @Override
public String resolveStringValue(String strVal) throws BeansException { @Nullable
public String resolveStringValue(@Nullable String strVal) throws BeansException {
String resolved = this.helper.replacePlaceholders(strVal, this.resolver); String resolved = this.helper.replacePlaceholders(strVal, this.resolver);
if (trimValues) { if (trimValues) {
resolved = resolved.trim(); resolved = resolved.trim();

View File

@ -17,6 +17,7 @@
package org.springframework.beans.factory.parsing; package org.springframework.beans.factory.parsing;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;
/** /**
* Simple implementation of {@link SourceExtractor} that returns {@code null} * Simple implementation of {@link SourceExtractor} that returns {@code null}
@ -34,7 +35,8 @@ public class NullSourceExtractor implements SourceExtractor {
* This implementation simply returns {@code null} for any input. * This implementation simply returns {@code null} for any input.
*/ */
@Override @Override
public Object extractSource(Object sourceCandidate, Resource definitionResource) { @Nullable
public Object extractSource(Object sourceCandidate, @Nullable Resource definitionResource) {
return null; return null;
} }

View File

@ -17,6 +17,7 @@
package org.springframework.beans.factory.parsing; package org.springframework.beans.factory.parsing;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;
/** /**
* Simple {@link SourceExtractor} implementation that just passes * Simple {@link SourceExtractor} implementation that just passes
@ -40,7 +41,7 @@ public class PassThroughSourceExtractor implements SourceExtractor {
* @return the supplied {@code sourceCandidate} * @return the supplied {@code sourceCandidate}
*/ */
@Override @Override
public Object extractSource(Object sourceCandidate, Resource definingResource) { public Object extractSource(Object sourceCandidate, @Nullable Resource definingResource) {
return sourceCandidate; return sourceCandidate;
} }

View File

@ -20,6 +20,7 @@ import java.util.ServiceLoader;
import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.config.AbstractFactoryBean; import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -54,7 +55,7 @@ public abstract class AbstractServiceLoaderBasedFactoryBean extends AbstractFact
} }
@Override @Override
public void setBeanClassLoader(ClassLoader beanClassLoader) { public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
this.beanClassLoader = beanClassLoader; this.beanClassLoader = beanClassLoader;
} }

View File

@ -195,7 +195,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
} }
@Override @Override
public <T> T getBean(String name, Class<T> requiredType) throws BeansException { public <T> T getBean(String name, @Nullable Class<T> requiredType) throws BeansException {
return doGetBean(name, requiredType, null, false); return doGetBean(name, requiredType, null, false);
} }
@ -698,7 +698,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
} }
@Override @Override
public void setBeanClassLoader(ClassLoader beanClassLoader) { public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
this.beanClassLoader = (beanClassLoader != null ? beanClassLoader : ClassUtils.getDefaultClassLoader()); this.beanClassLoader = (beanClassLoader != null ? beanClassLoader : ClassUtils.getDefaultClassLoader());
} }

View File

@ -18,6 +18,7 @@ package org.springframework.beans.factory.support;
import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.ConstructorArgumentValues; import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
/** /**
@ -129,7 +130,7 @@ public class ChildBeanDefinition extends AbstractBeanDefinition {
@Override @Override
public void setParentName(String parentName) { public void setParentName(@Nullable String parentName) {
this.parentName = parentName; this.parentName = parentName;
} }

View File

@ -373,17 +373,17 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
} }
@Override @Override
public String[] getBeanNamesForType(ResolvableType type) { public String[] getBeanNamesForType(@Nullable ResolvableType type) {
return doGetBeanNamesForType(type, true, true); return doGetBeanNamesForType(type, true, true);
} }
@Override @Override
public String[] getBeanNamesForType(Class<?> type) { public String[] getBeanNamesForType(@Nullable Class<?> type) {
return getBeanNamesForType(type, true, true); return getBeanNamesForType(type, true, true);
} }
@Override @Override
public String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) { public String[] getBeanNamesForType(@Nullable Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) {
if (!isConfigurationFrozen() || type == null || !allowEagerInit) { if (!isConfigurationFrozen() || type == null || !allowEagerInit) {
return doGetBeanNamesForType(ResolvableType.forRawClass(type), includeNonSingletons, allowEagerInit); return doGetBeanNamesForType(ResolvableType.forRawClass(type), includeNonSingletons, allowEagerInit);
} }
@ -497,12 +497,12 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
} }
@Override @Override
public <T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException { public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type) throws BeansException {
return getBeansOfType(type, true, true); return getBeansOfType(type, true, true);
} }
@Override @Override
public <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
throws BeansException { throws BeansException {
String[] beanNames = getBeanNamesForType(type, includeNonSingletons, allowEagerInit); String[] beanNames = getBeanNamesForType(type, includeNonSingletons, allowEagerInit);

View File

@ -17,6 +17,7 @@
package org.springframework.beans.factory.support; package org.springframework.beans.factory.support;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.lang.Nullable;
/** /**
* GenericBeanDefinition is a one-stop shop for standard bean definition purposes. * GenericBeanDefinition is a one-stop shop for standard bean definition purposes.
@ -64,7 +65,7 @@ public class GenericBeanDefinition extends AbstractBeanDefinition {
@Override @Override
public void setParentName(String parentName) { public void setParentName(@Nullable String parentName) {
this.parentName = parentName; this.parentName = parentName;
} }

View File

@ -21,6 +21,7 @@ import java.util.List;
import org.springframework.beans.BeanMetadataElement; import org.springframework.beans.BeanMetadataElement;
import org.springframework.beans.Mergeable; import org.springframework.beans.Mergeable;
import org.springframework.lang.Nullable;
/** /**
* Tag collection class used to hold managed List elements, which may * Tag collection class used to hold managed List elements, which may
@ -91,7 +92,7 @@ public class ManagedList<E> extends ArrayList<E> implements Mergeable, BeanMetad
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<E> merge(Object parent) { public List<E> merge(@Nullable Object parent) {
if (!this.mergeEnabled) { if (!this.mergeEnabled) {
throw new IllegalStateException("Not allowed to merge when the 'mergeEnabled' property is set to 'false'"); throw new IllegalStateException("Not allowed to merge when the 'mergeEnabled' property is set to 'false'");
} }

View File

@ -21,6 +21,7 @@ import java.util.Map;
import org.springframework.beans.BeanMetadataElement; import org.springframework.beans.BeanMetadataElement;
import org.springframework.beans.Mergeable; import org.springframework.beans.Mergeable;
import org.springframework.lang.Nullable;
/** /**
* Tag collection class used to hold managed Map values, which may * Tag collection class used to hold managed Map values, which may
@ -106,7 +107,7 @@ public class ManagedMap<K, V> extends LinkedHashMap<K, V> implements Mergeable,
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Object merge(Object parent) { public Object merge(@Nullable Object parent) {
if (!this.mergeEnabled) { if (!this.mergeEnabled) {
throw new IllegalStateException("Not allowed to merge when the 'mergeEnabled' property is set to 'false'"); throw new IllegalStateException("Not allowed to merge when the 'mergeEnabled' property is set to 'false'");
} }

View File

@ -20,6 +20,7 @@ import java.util.Properties;
import org.springframework.beans.BeanMetadataElement; import org.springframework.beans.BeanMetadataElement;
import org.springframework.beans.Mergeable; import org.springframework.beans.Mergeable;
import org.springframework.lang.Nullable;
/** /**
* Tag class which represents a Spring-managed {@link Properties} instance * Tag class which represents a Spring-managed {@link Properties} instance
@ -65,7 +66,7 @@ public class ManagedProperties extends Properties implements Mergeable, BeanMeta
@Override @Override
public Object merge(Object parent) { public Object merge(@Nullable Object parent) {
if (!this.mergeEnabled) { if (!this.mergeEnabled) {
throw new IllegalStateException("Not allowed to merge when the 'mergeEnabled' property is set to 'false'"); throw new IllegalStateException("Not allowed to merge when the 'mergeEnabled' property is set to 'false'");
} }

View File

@ -21,6 +21,7 @@ import java.util.Set;
import org.springframework.beans.BeanMetadataElement; import org.springframework.beans.BeanMetadataElement;
import org.springframework.beans.Mergeable; import org.springframework.beans.Mergeable;
import org.springframework.lang.Nullable;
/** /**
* Tag collection class used to hold managed Set values, which may * Tag collection class used to hold managed Set values, which may
@ -90,7 +91,7 @@ public class ManagedSet<E> extends LinkedHashSet<E> implements Mergeable, BeanMe
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Set<E> merge(Object parent) { public Set<E> merge(@Nullable Object parent) {
if (!this.mergeEnabled) { if (!this.mergeEnabled) {
throw new IllegalStateException("Not allowed to merge when the 'mergeEnabled' property is set to 'false'"); throw new IllegalStateException("Not allowed to merge when the 'mergeEnabled' property is set to 'false'");
} }

View File

@ -236,7 +236,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
} }
@Override @Override
public void setParentName(String parentName) { public void setParentName(@Nullable String parentName) {
if (parentName != null) { if (parentName != null) {
throw new IllegalArgumentException("Root bean cannot be changed into a child bean with parent reference"); throw new IllegalArgumentException("Root bean cannot be changed into a child bean with parent reference");
} }

View File

@ -58,7 +58,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
@Override @Override
public Object instantiate(RootBeanDefinition bd, String beanName, BeanFactory owner) { public Object instantiate(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner) {
// Don't override the class with CGLIB if no overrides. // Don't override the class with CGLIB if no overrides.
if (bd.getMethodOverrides().isEmpty()) { if (bd.getMethodOverrides().isEmpty()) {
Constructor<?> constructorToUse; Constructor<?> constructorToUse;
@ -107,7 +107,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
} }
@Override @Override
public Object instantiate(RootBeanDefinition bd, String beanName, BeanFactory owner, public Object instantiate(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner,
final Constructor<?> ctor, Object... args) { final Constructor<?> ctor, Object... args) {
if (bd.getMethodOverrides().isEmpty()) { if (bd.getMethodOverrides().isEmpty()) {
@ -141,8 +141,8 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
} }
@Override @Override
public Object instantiate(RootBeanDefinition bd, String beanName, BeanFactory owner, public Object instantiate(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner,
Object factoryBean, final Method factoryMethod, Object... args) { @Nullable Object factoryBean, final Method factoryMethod, Object... args) {
try { try {
if (System.getSecurityManager() != null) { if (System.getSecurityManager() != null) {

View File

@ -34,6 +34,7 @@ import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
import org.springframework.beans.factory.SmartFactoryBean; import org.springframework.beans.factory.SmartFactoryBean;
import org.springframework.core.ResolvableType; import org.springframework.core.ResolvableType;
import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.annotation.AnnotationUtils;
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;
@ -132,7 +133,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T getBean(String name, Class<T> requiredType) throws BeansException { public <T> T getBean(String name, @Nullable Class<T> requiredType) throws BeansException {
Object bean = getBean(name); Object bean = getBean(name);
if (requiredType != null && !requiredType.isAssignableFrom(bean.getClass())) { if (requiredType != null && !requiredType.isAssignableFrom(bean.getClass())) {
throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass()); throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
@ -247,7 +248,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
} }
@Override @Override
public String[] getBeanNamesForType(ResolvableType type) { public String[] getBeanNamesForType(@Nullable ResolvableType type) {
boolean isFactoryType = false; boolean isFactoryType = false;
if (type != null) { if (type != null) {
Class<?> resolved = type.resolve(); Class<?> resolved = type.resolve();
@ -275,23 +276,23 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
} }
@Override @Override
public String[] getBeanNamesForType(Class<?> type) { public String[] getBeanNamesForType(@Nullable Class<?> type) {
return getBeanNamesForType(ResolvableType.forClass(type)); return getBeanNamesForType(ResolvableType.forClass(type));
} }
@Override @Override
public String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) { public String[] getBeanNamesForType(@Nullable Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) {
return getBeanNamesForType(ResolvableType.forClass(type)); return getBeanNamesForType(ResolvableType.forClass(type));
} }
@Override @Override
public <T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException { public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type) throws BeansException {
return getBeansOfType(type, true, true); return getBeansOfType(type, true, true);
} }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
throws BeansException { throws BeansException {
boolean isFactoryType = (type != null && FactoryBean.class.isAssignableFrom(type)); boolean isFactoryType = (type != null && FactoryBean.class.isAssignableFrom(type));

View File

@ -25,6 +25,7 @@ import org.springframework.beans.factory.parsing.BeanComponentDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils; import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@ -147,7 +148,7 @@ public abstract class AbstractBeanDefinitionParser implements BeanDefinitionPars
* @see #parse(org.w3c.dom.Element, ParserContext) * @see #parse(org.w3c.dom.Element, ParserContext)
* @see #postProcessComponentDefinition(org.springframework.beans.factory.parsing.BeanComponentDefinition) * @see #postProcessComponentDefinition(org.springframework.beans.factory.parsing.BeanComponentDefinition)
*/ */
protected abstract AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext); protected abstract AbstractBeanDefinition parseInternal(@Nullable Element element, @Nullable ParserContext parserContext);
/** /**
* Should an ID be generated instead of read from the passed in {@link Element}? * Should an ID be generated instead of read from the passed in {@link Element}?

View File

@ -58,7 +58,7 @@ public abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDef
* @see #doParse * @see #doParse
*/ */
@Override @Override
protected final AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { protected final AbstractBeanDefinition parseInternal(@Nullable Element element, @Nullable ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(); BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition();
String parentName = getParentName(element); String parentName = getParentName(element);
if (parentName != null) { if (parentName != null) {

View File

@ -49,6 +49,7 @@ import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService; import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.lang.Nullable;
import org.springframework.tests.Assume; import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup; import org.springframework.tests.TestGroup;
import org.springframework.tests.sample.beans.BooleanTestBean; import org.springframework.tests.sample.beans.BooleanTestBean;
@ -461,7 +462,7 @@ public abstract class AbstractPropertyAccessorTests {
AbstractPropertyAccessor accessor = createAccessor(target); AbstractPropertyAccessor accessor = createAccessor(target);
accessor.setConversionService(new GenericConversionService() { accessor.setConversionService(new GenericConversionService() {
@Override @Override
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { public Object convert(@Nullable Object source, @Nullable TypeDescriptor sourceType, TypeDescriptor targetType) {
throw new ConversionFailedException(sourceType, targetType, source, null); throw new ConversionFailedException(sourceType, targetType, source, null);
} }
}); });

View File

@ -83,6 +83,7 @@ import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService; import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource; import org.springframework.core.io.UrlResource;
import org.springframework.lang.Nullable;
import org.springframework.tests.Assume; import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup; import org.springframework.tests.TestGroup;
import org.springframework.tests.sample.beans.DependenciesBean; import org.springframework.tests.sample.beans.DependenciesBean;
@ -3120,7 +3121,7 @@ public class DefaultListableBeanFactoryTests {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Object convertIfNecessary(Object value, Class requiredType) { public Object convertIfNecessary(Object value, @Nullable Class requiredType) {
if (value instanceof String && Float.class.isAssignableFrom(requiredType)) { if (value instanceof String && Float.class.isAssignableFrom(requiredType)) {
try { try {
return new Float(this.numberFormat.parse((String) value).floatValue()); return new Float(this.numberFormat.parse((String) value).floatValue());
@ -3139,13 +3140,13 @@ public class DefaultListableBeanFactoryTests {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Object convertIfNecessary(Object value, Class requiredType, MethodParameter methodParam) { public Object convertIfNecessary(Object value, @Nullable Class requiredType, @Nullable MethodParameter methodParam) {
return convertIfNecessary(value, requiredType); return convertIfNecessary(value, requiredType);
} }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Object convertIfNecessary(Object value, Class requiredType, Field field) { public Object convertIfNecessary(Object value, @Nullable Class requiredType, @Nullable Field field) {
return convertIfNecessary(value, requiredType); return convertIfNecessary(value, requiredType);
} }
} }

View File

@ -22,6 +22,7 @@ import java.util.function.Function;
import com.github.benmanes.caffeine.cache.LoadingCache; import com.github.benmanes.caffeine.cache.LoadingCache;
import org.springframework.cache.support.AbstractValueAdaptingCache; import org.springframework.cache.support.AbstractValueAdaptingCache;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
@ -82,7 +83,7 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
} }
@Override @Override
public ValueWrapper get(Object key) { public ValueWrapper get(@Nullable Object key) {
if (this.cache instanceof LoadingCache) { if (this.cache instanceof LoadingCache) {
Object value = ((LoadingCache<Object, Object>) this.cache).get(key); Object value = ((LoadingCache<Object, Object>) this.cache).get(key);
return toValueWrapper(value); return toValueWrapper(value);
@ -92,7 +93,8 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public <T> T get(Object key, final Callable<T> valueLoader) { @Nullable
public <T> T get(@Nullable Object key, final Callable<T> valueLoader) {
return (T) fromStoreValue(this.cache.get(key, new LoadFunction(valueLoader))); return (T) fromStoreValue(this.cache.get(key, new LoadFunction(valueLoader)));
} }
@ -102,19 +104,20 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
} }
@Override @Override
public void put(Object key, Object value) { public void put(@Nullable Object key, @Nullable Object value) {
this.cache.put(key, toStoreValue(value)); this.cache.put(key, toStoreValue(value));
} }
@Override @Override
public ValueWrapper putIfAbsent(Object key, final Object value) { @Nullable
public ValueWrapper putIfAbsent(@Nullable Object key, @Nullable final Object value) {
PutIfAbsentFunction callable = new PutIfAbsentFunction(value); PutIfAbsentFunction callable = new PutIfAbsentFunction(value);
Object result = this.cache.get(key, callable); Object result = this.cache.get(key, callable);
return (callable.called ? null : toValueWrapper(result)); return (callable.called ? null : toValueWrapper(result));
} }
@Override @Override
public void evict(Object key) { public void evict(@Nullable Object key) {
this.cache.invalidate(key); this.cache.invalidate(key);
} }

View File

@ -24,6 +24,7 @@ import net.sf.ehcache.Status;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.cache.support.SimpleValueWrapper; import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
@ -63,14 +64,15 @@ public class EhCacheCache implements Cache {
} }
@Override @Override
public ValueWrapper get(Object key) { public ValueWrapper get(@Nullable Object key) {
Element element = lookup(key); Element element = lookup(key);
return toValueWrapper(element); return toValueWrapper(element);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public <T> T get(Object key, Callable<T> valueLoader) { @Nullable
public <T> T get(@Nullable Object key, Callable<T> valueLoader) {
Element element = lookup(key); Element element = lookup(key);
if (element != null) { if (element != null) {
return (T) element.getObjectValue(); return (T) element.getObjectValue();
@ -107,7 +109,8 @@ public class EhCacheCache implements Cache {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T get(Object key, Class<T> type) { @Nullable
public <T> T get(@Nullable Object key, Class<T> type) {
Element element = this.cache.get(key); Element element = this.cache.get(key);
Object value = (element != null ? element.getObjectValue() : null); Object value = (element != null ? element.getObjectValue() : null);
if (value != null && type != null && !type.isInstance(value)) { if (value != null && type != null && !type.isInstance(value)) {
@ -117,18 +120,18 @@ public class EhCacheCache implements Cache {
} }
@Override @Override
public void put(Object key, Object value) { public void put(@Nullable Object key, @Nullable Object value) {
this.cache.put(new Element(key, value)); this.cache.put(new Element(key, value));
} }
@Override @Override
public ValueWrapper putIfAbsent(Object key, Object value) { public ValueWrapper putIfAbsent(@Nullable Object key, @Nullable Object value) {
Element existingElement = this.cache.putIfAbsent(new Element(key, value)); Element existingElement = this.cache.putIfAbsent(new Element(key, value));
return toValueWrapper(existingElement); return toValueWrapper(existingElement);
} }
@Override @Override
public void evict(Object key) { public void evict(@Nullable Object key) {
this.cache.remove(key); this.cache.remove(key);
} }

View File

@ -22,6 +22,7 @@ import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.MutableEntry; import javax.cache.processor.MutableEntry;
import org.springframework.cache.support.AbstractValueAdaptingCache; import org.springframework.cache.support.AbstractValueAdaptingCache;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
@ -75,7 +76,7 @@ public class JCacheCache extends AbstractValueAdaptingCache {
} }
@Override @Override
public <T> T get(Object key, Callable<T> valueLoader) { public <T> T get(@Nullable Object key, Callable<T> valueLoader) {
try { try {
return this.cache.invoke(key, new ValueLoaderEntryProcessor<T>(), valueLoader); return this.cache.invoke(key, new ValueLoaderEntryProcessor<T>(), valueLoader);
} }
@ -85,18 +86,18 @@ public class JCacheCache extends AbstractValueAdaptingCache {
} }
@Override @Override
public void put(Object key, Object value) { public void put(@Nullable Object key, @Nullable Object value) {
this.cache.put(key, toStoreValue(value)); this.cache.put(key, toStoreValue(value));
} }
@Override @Override
public ValueWrapper putIfAbsent(Object key, Object value) { public ValueWrapper putIfAbsent(@Nullable Object key, @Nullable Object value) {
boolean set = this.cache.putIfAbsent(key, toStoreValue(value)); boolean set = this.cache.putIfAbsent(key, toStoreValue(value));
return (set ? null : get(key)); return (set ? null : get(key));
} }
@Override @Override
public void evict(Object key) { public void evict(@Nullable Object key) {
this.cache.remove(key); this.cache.remove(key);
} }

View File

@ -69,7 +69,7 @@ public class JCacheManagerFactoryBean
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.beanClassLoader = classLoader; this.beanClassLoader = classLoader;
} }

View File

@ -25,6 +25,7 @@ import org.springframework.cache.jcache.interceptor.JCacheOperationSource;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role; import org.springframework.context.annotation.Role;
import org.springframework.lang.Nullable;
/** /**
* Abstract JSR-107 specific {@code @Configuration} class providing common * Abstract JSR-107 specific {@code @Configuration} class providing common
@ -40,7 +41,7 @@ public class AbstractJCacheConfiguration extends AbstractCachingConfiguration {
protected CacheResolver exceptionCacheResolver; protected CacheResolver exceptionCacheResolver;
@Override @Override
protected void useCachingConfigurer(CachingConfigurer config) { protected void useCachingConfigurer(@Nullable CachingConfigurer config) {
super.useCachingConfigurer(config); super.useCachingConfigurer(config);
if (config instanceof JCacheConfigurer) { if (config instanceof JCacheConfigurer) {
this.exceptionCacheResolver = ((JCacheConfigurer) config).exceptionCacheResolver(); this.exceptionCacheResolver = ((JCacheConfigurer) config).exceptionCacheResolver();

View File

@ -19,6 +19,7 @@ package org.springframework.cache.transaction;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.lang.Nullable;
import org.springframework.transaction.support.TransactionSynchronizationAdapter; import org.springframework.transaction.support.TransactionSynchronizationAdapter;
import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -71,22 +72,22 @@ public class TransactionAwareCacheDecorator implements Cache {
} }
@Override @Override
public ValueWrapper get(Object key) { public ValueWrapper get(@Nullable Object key) {
return this.targetCache.get(key); return this.targetCache.get(key);
} }
@Override @Override
public <T> T get(Object key, Class<T> type) { public <T> T get(@Nullable Object key, Class<T> type) {
return this.targetCache.get(key, type); return this.targetCache.get(key, type);
} }
@Override @Override
public <T> T get(Object key, Callable<T> valueLoader) { public <T> T get(@Nullable Object key, Callable<T> valueLoader) {
return this.targetCache.get(key, valueLoader); return this.targetCache.get(key, valueLoader);
} }
@Override @Override
public void put(final Object key, final Object value) { public void put(@Nullable final Object key, @Nullable final Object value) {
if (TransactionSynchronizationManager.isSynchronizationActive()) { if (TransactionSynchronizationManager.isSynchronizationActive()) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override @Override
@ -101,12 +102,12 @@ public class TransactionAwareCacheDecorator implements Cache {
} }
@Override @Override
public ValueWrapper putIfAbsent(final Object key, final Object value) { public ValueWrapper putIfAbsent(@Nullable final Object key, @Nullable final Object value) {
return this.targetCache.putIfAbsent(key, value); return this.targetCache.putIfAbsent(key, value);
} }
@Override @Override
public void evict(final Object key) { public void evict(@Nullable final Object key) {
if (TransactionSynchronizationManager.isSynchronizationActive()) { if (TransactionSynchronizationManager.isSynchronizationActive()) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override @Override

View File

@ -35,6 +35,7 @@ import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.support.ArgumentConvertingMethodInvoker; import org.springframework.beans.support.ArgumentConvertingMethodInvoker;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.MethodInvoker; import org.springframework.util.MethodInvoker;
@ -141,7 +142,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.beanClassLoader = classLoader; this.beanClassLoader = classLoader;
} }

View File

@ -27,6 +27,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportAware; import org.springframework.context.annotation.ImportAware;
import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
/** /**
@ -80,7 +81,7 @@ public abstract class AbstractCachingConfiguration implements ImportAware {
/** /**
* Extract the configuration from the nominated {@link CachingConfigurer}. * Extract the configuration from the nominated {@link CachingConfigurer}.
*/ */
protected void useCachingConfigurer(CachingConfigurer config) { protected void useCachingConfigurer(@Nullable CachingConfigurer config) {
this.cacheManager = config.cacheManager(); this.cacheManager = config.cacheManager();
this.cacheResolver = config.cacheResolver(); this.cacheResolver = config.cacheResolver();
this.keyGenerator = config.keyGenerator(); this.keyGenerator = config.keyGenerator();

View File

@ -137,7 +137,8 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public <T> T get(Object key, Callable<T> valueLoader) { @Nullable
public <T> T get(@Nullable Object key, Callable<T> valueLoader) {
if (this.store.containsKey(key)) { if (this.store.containsKey(key)) {
return (T) get(key).get(); return (T) get(key).get();
} }
@ -154,18 +155,19 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
} }
@Override @Override
public void put(Object key, Object value) { public void put(@Nullable Object key, @Nullable Object value) {
this.store.put(key, toStoreValue(value)); this.store.put(key, toStoreValue(value));
} }
@Override @Override
public ValueWrapper putIfAbsent(Object key, Object value) { @Nullable
public ValueWrapper putIfAbsent(@Nullable Object key, @Nullable Object value) {
Object existing = this.store.putIfAbsent(key, toStoreValue(value)); Object existing = this.store.putIfAbsent(key, toStoreValue(value));
return toValueWrapper(existing); return toValueWrapper(existing);
} }
@Override @Override
public void evict(Object key) { public void evict(@Nullable Object key) {
this.store.remove(key); this.store.remove(key);
} }
@ -175,7 +177,7 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
} }
@Override @Override
protected Object toStoreValue(Object userValue) { protected Object toStoreValue(@Nullable Object userValue) {
Object storeValue = super.toStoreValue(userValue); Object storeValue = super.toStoreValue(userValue);
if (this.serialization != null) { if (this.serialization != null) {
try { try {
@ -203,7 +205,7 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
} }
@Override @Override
protected Object fromStoreValue(Object storeValue) { protected Object fromStoreValue(@Nullable Object storeValue) {
if (this.serialization != null) { if (this.serialization != null) {
try { try {
return super.fromStoreValue(deserializeValue(storeValue)); return super.fromStoreValue(deserializeValue(storeValue));

View File

@ -146,7 +146,7 @@ public class ConcurrentMapCacheManager implements CacheManager, BeanClassLoaderA
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.serialization = new SerializationDelegate(classLoader); this.serialization = new SerializationDelegate(classLoader);
// Need to recreate all Cache instances with new ClassLoader in store-by-value mode... // Need to recreate all Cache instances with new ClassLoader in store-by-value mode...
if (isStoreByValue()) { if (isStoreByValue()) {

View File

@ -95,6 +95,6 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi
* @return the cache name(s) to resolve or {@code null} if no cache should be resolved * @return the cache name(s) to resolve or {@code null} if no cache should be resolved
*/ */
@Nullable @Nullable
protected abstract Collection<String> getCacheNames(CacheOperationInvocationContext<?> context); protected abstract Collection<String> getCacheNames(@Nullable CacheOperationInvocationContext<?> context);
} }

View File

@ -83,7 +83,7 @@ public abstract class AbstractFallbackCacheOperationSource implements CacheOpera
* is not cacheable * is not cacheable
*/ */
@Override @Override
public Collection<CacheOperation> getCacheOperations(Method method, Class<?> targetClass) { public Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass) {
if (method.getDeclaringClass() == Object.class) { if (method.getDeclaringClass() == Object.class) {
return null; return null;
} }

View File

@ -35,7 +35,7 @@ import org.springframework.util.ObjectUtils;
abstract class CacheOperationSourcePointcut extends StaticMethodMatcherPointcut implements Serializable { abstract class CacheOperationSourcePointcut extends StaticMethodMatcherPointcut implements Serializable {
@Override @Override
public boolean matches(Method method, Class<?> targetClass) { public boolean matches(Method method, @Nullable Class<?> targetClass) {
CacheOperationSource cas = getCacheOperationSource(); CacheOperationSource cas = getCacheOperationSource();
return (cas != null && !CollectionUtils.isEmpty(cas.getCacheOperations(method, targetClass))); return (cas != null && !CollectionUtils.isEmpty(cas.getCacheOperations(method, targetClass)));
} }

View File

@ -21,6 +21,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
@ -54,7 +55,7 @@ public class CompositeCacheOperationSource implements CacheOperationSource, Seri
} }
@Override @Override
public Collection<CacheOperation> getCacheOperations(Method method, Class<?> targetClass) { public Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass) {
Collection<CacheOperation> ops = null; Collection<CacheOperation> ops = null;
for (CacheOperationSource source : this.cacheOperationSources) { for (CacheOperationSource source : this.cacheOperationSources) {

View File

@ -25,6 +25,7 @@ import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.PatternMatchUtils; import org.springframework.util.PatternMatchUtils;
@ -76,7 +77,7 @@ public class NameMatchCacheOperationSource implements CacheOperationSource, Seri
} }
@Override @Override
public Collection<CacheOperation> getCacheOperations(Method method, Class<?> targetClass) { public Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass) {
// look for direct name match // look for direct name match
String methodName = method.getName(); String methodName = method.getName();
Collection<CacheOperation> ops = this.nameMap.get(methodName); Collection<CacheOperation> ops = this.nameMap.get(methodName);

View File

@ -22,6 +22,7 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.lang.Nullable;
/** /**
* A {@link CacheResolver} that forces the resolution to a configurable * A {@link CacheResolver} that forces the resolution to a configurable
@ -50,7 +51,7 @@ public class NamedCacheResolver extends AbstractCacheResolver {
} }
@Override @Override
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) { protected Collection<String> getCacheNames(@Nullable CacheOperationInvocationContext<?> context) {
return this.cacheNames; return this.cacheNames;
} }

View File

@ -20,6 +20,7 @@ import java.util.Collection;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.lang.Nullable;
/** /**
* A simple {@link CacheResolver} that resolves the {@link Cache} instance(s) * A simple {@link CacheResolver} that resolves the {@link Cache} instance(s)
@ -40,7 +41,7 @@ public class SimpleCacheResolver extends AbstractCacheResolver {
} }
@Override @Override
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) { protected Collection<String> getCacheNames(@Nullable CacheOperationInvocationContext<?> context) {
return context.getOperation().getCacheNames(); return context.getOperation().getCacheNames();
} }

View File

@ -53,14 +53,16 @@ public abstract class AbstractValueAdaptingCache implements Cache {
} }
@Override @Override
public ValueWrapper get(Object key) { @Nullable
public ValueWrapper get(@Nullable Object key) {
Object value = lookup(key); Object value = lookup(key);
return toValueWrapper(value); return toValueWrapper(value);
} }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T get(Object key, Class<T> type) { @Nullable
public <T> T get(@Nullable Object key, Class<T> type) {
Object value = fromStoreValue(lookup(key)); Object value = fromStoreValue(lookup(key));
if (value != null && type != null && !type.isInstance(value)) { if (value != null && type != null && !type.isInstance(value)) {
throw new IllegalStateException("Cached value is not of required type [" + type.getName() + "]: " + value); throw new IllegalStateException("Cached value is not of required type [" + type.getName() + "]: " + value);
@ -115,6 +117,7 @@ public abstract class AbstractValueAdaptingCache implements Cache {
* @param storeValue the original value * @param storeValue the original value
* @return the wrapped value * @return the wrapped value
*/ */
@Nullable
protected Cache.ValueWrapper toValueWrapper(Object storeValue) { protected Cache.ValueWrapper toValueWrapper(Object storeValue) {
return (storeValue != null ? new SimpleValueWrapper(fromStoreValue(storeValue)) : null); return (storeValue != null ? new SimpleValueWrapper(fromStoreValue(storeValue)) : null);
} }

View File

@ -19,6 +19,7 @@ package org.springframework.cache.support;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.lang.Nullable;
/** /**
* A no operation {@link Cache} implementation suitable * A no operation {@link Cache} implementation suitable
@ -47,21 +48,21 @@ public class NoOpCache implements Cache {
} }
@Override @Override
public void evict(Object key) { public void evict(@Nullable Object key) {
} }
@Override @Override
public ValueWrapper get(Object key) { public ValueWrapper get(@Nullable Object key) {
return null; return null;
} }
@Override @Override
public <T> T get(Object key, Class<T> type) { public <T> T get(@Nullable Object key, Class<T> type) {
return null; return null;
} }
@Override @Override
public <T> T get(Object key, Callable<T> valueLoader) { public <T> T get(@Nullable Object key, Callable<T> valueLoader) {
try { try {
return valueLoader.call(); return valueLoader.call();
} }
@ -81,11 +82,12 @@ public class NoOpCache implements Cache {
} }
@Override @Override
public void put(Object key, Object value) { public void put(@Nullable Object key, @Nullable Object value) {
} }
@Override @Override
public ValueWrapper putIfAbsent(Object key, Object value) { @Nullable
public ValueWrapper putIfAbsent(@Nullable Object key, @Nullable Object value) {
return null; return null;
} }

View File

@ -214,7 +214,7 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex
} }
@Override @Override
public <T> void registerBean(String beanName, Class<T> beanClass, Supplier<T> supplier, public <T> void registerBean(@Nullable String beanName, @Nullable Class<T> beanClass, Supplier<T> supplier,
BeanDefinitionCustomizer... customizers) { BeanDefinitionCustomizer... customizers) {
this.reader.doRegisterBean(beanClass, supplier, beanName, null, customizers); this.reader.doRegisterBean(beanClass, supplier, beanName, null, customizers);

View File

@ -61,6 +61,7 @@ import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.classreading.CachingMetadataReaderFactory; import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -201,7 +202,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
} }
@Override @Override
public void setBeanClassLoader(ClassLoader beanClassLoader) { public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
this.beanClassLoader = beanClassLoader; this.beanClassLoader = beanClassLoader;
if (!this.setMetadataReaderFactoryCalled) { if (!this.setMetadataReaderFactoryCalled) {
this.metadataReaderFactory = new CachingMetadataReaderFactory(beanClassLoader); this.metadataReaderFactory = new CachingMetadataReaderFactory(beanClassLoader);

View File

@ -26,6 +26,7 @@ import org.springframework.context.weaving.DefaultContextLoadTimeWeaver;
import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.instrument.classloading.LoadTimeWeaver; import org.springframework.instrument.classloading.LoadTimeWeaver;
import org.springframework.lang.Nullable;
/** /**
* {@code @Configuration} class that registers a {@link LoadTimeWeaver} bean. * {@code @Configuration} class that registers a {@link LoadTimeWeaver} bean.
@ -64,7 +65,7 @@ public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoade
} }
@Override @Override
public void setBeanClassLoader(ClassLoader beanClassLoader) { public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
this.beanClassLoader = beanClassLoader; this.beanClassLoader = beanClassLoader;
} }

View File

@ -25,6 +25,7 @@ import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext; import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.jmx.export.annotation.AnnotationMBeanExporter; import org.springframework.jmx.export.annotation.AnnotationMBeanExporter;
import org.springframework.jmx.support.RegistrationPolicy; import org.springframework.jmx.support.RegistrationPolicy;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@ -60,7 +61,7 @@ class MBeanExportBeanDefinitionParser extends AbstractBeanDefinitionParser {
} }
@Override @Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { protected AbstractBeanDefinition parseInternal(@Nullable Element element, @Nullable ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(AnnotationMBeanExporter.class); BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(AnnotationMBeanExporter.class);
// Mark as infrastructure bean and attach source location. // Mark as infrastructure bean and attach source location.

View File

@ -63,7 +63,7 @@ class MBeanServerBeanDefinitionParser extends AbstractBeanDefinitionParser {
} }
@Override @Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { protected AbstractBeanDefinition parseInternal(@Nullable Element element, @Nullable ParserContext parserContext) {
String agentId = element.getAttribute(AGENT_ID_ATTRIBUTE); String agentId = element.getAttribute(AGENT_ID_ATTRIBUTE);
if (StringUtils.hasText(agentId)) { if (StringUtils.hasText(agentId)) {
RootBeanDefinition bd = new RootBeanDefinition(MBeanServerFactoryBean.class); RootBeanDefinition bd = new RootBeanDefinition(MBeanServerFactoryBean.class);

View File

@ -33,6 +33,7 @@ import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.core.ResolvableType; import org.springframework.core.ResolvableType;
import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
@ -71,7 +72,7 @@ public abstract class AbstractApplicationEventMulticaster
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.beanClassLoader = classLoader; this.beanClassLoader = classLoader;
} }

View File

@ -25,6 +25,7 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.core.ResolvableType; import org.springframework.core.ResolvableType;
import org.springframework.lang.Nullable;
import org.springframework.util.ErrorHandler; import org.springframework.util.ErrorHandler;
/** /**
@ -123,7 +124,7 @@ public class SimpleApplicationEventMulticaster extends AbstractApplicationEventM
} }
@Override @Override
public void multicastEvent(final ApplicationEvent event, ResolvableType eventType) { public void multicastEvent(final ApplicationEvent event, @Nullable ResolvableType eventType) {
ResolvableType type = (eventType != null ? eventType : resolveDefaultEventType(event)); ResolvableType type = (eventType != null ? eventType : resolveDefaultEventType(event));
for (final ApplicationListener<?> listener : getApplicationListeners(event, type)) { for (final ApplicationListener<?> listener : getApplicationListeners(event, type)) {
Executor executor = getTaskExecutor(); Executor executor = getTaskExecutor();

View File

@ -76,6 +76,7 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
@ -461,7 +462,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* @see ConfigurableEnvironment#merge(ConfigurableEnvironment) * @see ConfigurableEnvironment#merge(ConfigurableEnvironment)
*/ */
@Override @Override
public void setParent(ApplicationContext parent) { public void setParent(@Nullable ApplicationContext parent) {
this.parent = parent; this.parent = parent;
if (parent != null) { if (parent != null) {
Environment parentEnvironment = parent.getEnvironment(); Environment parentEnvironment = parent.getEnvironment();
@ -844,7 +845,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
if (!beanFactory.hasEmbeddedValueResolver()) { if (!beanFactory.hasEmbeddedValueResolver()) {
beanFactory.addEmbeddedValueResolver(new StringValueResolver() { beanFactory.addEmbeddedValueResolver(new StringValueResolver() {
@Override @Override
public String resolveStringValue(String strVal) { public String resolveStringValue(@Nullable String strVal) {
return getEnvironment().resolvePlaceholders(strVal); return getEnvironment().resolvePlaceholders(strVal);
} }
}); });
@ -1081,7 +1082,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
} }
@Override @Override
public <T> T getBean(String name, Class<T> requiredType) throws BeansException { public <T> T getBean(String name, @Nullable Class<T> requiredType) throws BeansException {
assertBeanFactoryActive(); assertBeanFactoryActive();
return getBeanFactory().getBean(name, requiredType); return getBeanFactory().getBean(name, requiredType);
} }
@ -1165,31 +1166,31 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
} }
@Override @Override
public String[] getBeanNamesForType(ResolvableType type) { public String[] getBeanNamesForType(@Nullable ResolvableType type) {
assertBeanFactoryActive(); assertBeanFactoryActive();
return getBeanFactory().getBeanNamesForType(type); return getBeanFactory().getBeanNamesForType(type);
} }
@Override @Override
public String[] getBeanNamesForType(Class<?> type) { public String[] getBeanNamesForType(@Nullable Class<?> type) {
assertBeanFactoryActive(); assertBeanFactoryActive();
return getBeanFactory().getBeanNamesForType(type); return getBeanFactory().getBeanNamesForType(type);
} }
@Override @Override
public String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) { public String[] getBeanNamesForType(@Nullable Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) {
assertBeanFactoryActive(); assertBeanFactoryActive();
return getBeanFactory().getBeanNamesForType(type, includeNonSingletons, allowEagerInit); return getBeanFactory().getBeanNamesForType(type, includeNonSingletons, allowEagerInit);
} }
@Override @Override
public <T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException { public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type) throws BeansException {
assertBeanFactoryActive(); assertBeanFactoryActive();
return getBeanFactory().getBeansOfType(type); return getBeanFactory().getBeansOfType(type);
} }
@Override @Override
public <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
throws BeansException { throws BeansException {
assertBeanFactoryActive(); assertBeanFactoryActive();
@ -1249,12 +1250,12 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
//--------------------------------------------------------------------- //---------------------------------------------------------------------
@Override @Override
public String getMessage(String code, Object args[], String defaultMessage, Locale locale) { public String getMessage(String code, @Nullable Object args[], String defaultMessage, Locale locale) {
return getMessageSource().getMessage(code, args, defaultMessage, locale); return getMessageSource().getMessage(code, args, defaultMessage, locale);
} }
@Override @Override
public String getMessage(String code, Object args[], Locale locale) throws NoSuchMessageException { public String getMessage(String code, @Nullable Object args[], Locale locale) throws NoSuchMessageException {
return getMessageSource().getMessage(code, args, locale); return getMessageSource().getMessage(code, args, locale);
} }

View File

@ -72,7 +72,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
@Override @Override
public void setParentMessageSource(MessageSource parent) { public void setParentMessageSource(@Nullable MessageSource parent) {
this.parentMessageSource = parent; this.parentMessageSource = parent;
} }
@ -134,7 +134,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
@Override @Override
public final String getMessage(String code, Object[] args, String defaultMessage, Locale locale) { public final String getMessage(String code, @Nullable Object[] args, String defaultMessage, Locale locale) {
String msg = getMessageInternal(code, args, locale); String msg = getMessageInternal(code, args, locale);
if (msg != null) { if (msg != null) {
return msg; return msg;
@ -149,7 +149,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
} }
@Override @Override
public final String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException { public final String getMessage(String code, @Nullable Object[] args, Locale locale) throws NoSuchMessageException {
String msg = getMessageInternal(code, args, locale); String msg = getMessageInternal(code, args, locale);
if (msg != null) { if (msg != null) {
return msg; return msg;

View File

@ -22,6 +22,7 @@ import org.springframework.context.HierarchicalMessageSource;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceResolvable; import org.springframework.context.MessageSourceResolvable;
import org.springframework.context.NoSuchMessageException; import org.springframework.context.NoSuchMessageException;
import org.springframework.lang.Nullable;
/** /**
* Empty {@link MessageSource} that delegates all calls to the parent MessageSource. * Empty {@link MessageSource} that delegates all calls to the parent MessageSource.
@ -40,7 +41,7 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie
@Override @Override
public void setParentMessageSource(MessageSource parent) { public void setParentMessageSource(@Nullable MessageSource parent) {
this.parentMessageSource = parent; this.parentMessageSource = parent;
} }
@ -51,7 +52,7 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie
@Override @Override
public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) { public String getMessage(String code, @Nullable Object[] args, String defaultMessage, Locale locale) {
if (this.parentMessageSource != null) { if (this.parentMessageSource != null) {
return this.parentMessageSource.getMessage(code, args, defaultMessage, locale); return this.parentMessageSource.getMessage(code, args, defaultMessage, locale);
} }
@ -61,7 +62,7 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie
} }
@Override @Override
public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException { public String getMessage(String code, @Nullable Object[] args, Locale locale) throws NoSuchMessageException {
if (this.parentMessageSource != null) { if (this.parentMessageSource != null) {
return this.parentMessageSource.getMessage(code, args, locale); return this.parentMessageSource.getMessage(code, args, locale);
} }

View File

@ -150,7 +150,7 @@ public class GenericApplicationContext extends AbstractApplicationContext implem
* @see org.springframework.beans.factory.config.ConfigurableBeanFactory#setParentBeanFactory * @see org.springframework.beans.factory.config.ConfigurableBeanFactory#setParentBeanFactory
*/ */
@Override @Override
public void setParent(ApplicationContext parent) { public void setParent(@Nullable ApplicationContext parent) {
super.setParent(parent); super.setParent(parent);
this.beanFactory.setParentBeanFactory(getInternalParentBeanFactory()); this.beanFactory.setParentBeanFactory(getInternalParentBeanFactory());
} }
@ -238,7 +238,7 @@ public class GenericApplicationContext extends AbstractApplicationContext implem
} }
@Override @Override
public void setClassLoader(ClassLoader classLoader) { public void setClassLoader(@Nullable ClassLoader classLoader) {
super.setClassLoader(classLoader); super.setClassLoader(classLoader);
this.customClassLoader = true; this.customClassLoader = true;
} }

View File

@ -31,6 +31,7 @@ import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.core.env.PropertySource; import org.springframework.core.env.PropertySource;
import org.springframework.core.env.PropertySources; import org.springframework.core.env.PropertySources;
import org.springframework.core.env.PropertySourcesPropertyResolver; import org.springframework.core.env.PropertySourcesPropertyResolver;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.StringValueResolver; import org.springframework.util.StringValueResolver;
@ -166,7 +167,8 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
StringValueResolver valueResolver = new StringValueResolver() { StringValueResolver valueResolver = new StringValueResolver() {
@Override @Override
public String resolveStringValue(String strVal) { @Nullable
public String resolveStringValue(@Nullable String strVal) {
String resolved = (ignoreUnresolvablePlaceholders ? String resolved = (ignoreUnresolvablePlaceholders ?
propertyResolver.resolvePlaceholders(strVal) : propertyResolver.resolvePlaceholders(strVal) :
propertyResolver.resolveRequiredPlaceholders(strVal)); propertyResolver.resolveRequiredPlaceholders(strVal));

View File

@ -114,7 +114,7 @@ public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSou
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.beanClassLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader()); this.beanClassLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
} }

View File

@ -53,7 +53,7 @@ public class AspectJWeavingEnabler
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.beanClassLoader = classLoader; this.beanClassLoader = classLoader;
} }

View File

@ -69,7 +69,7 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
LoadTimeWeaver serverSpecificLoadTimeWeaver = createServerSpecificLoadTimeWeaver(classLoader); LoadTimeWeaver serverSpecificLoadTimeWeaver = createServerSpecificLoadTimeWeaver(classLoader);
if (serverSpecificLoadTimeWeaver != null) { if (serverSpecificLoadTimeWeaver != null) {
if (logger.isInfoEnabled()) { if (logger.isInfoEnabled()) {

View File

@ -21,6 +21,7 @@ import javax.naming.NamingException;
import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.FactoryBean;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
/** /**
@ -78,7 +79,7 @@ public class LocalStatelessSessionProxyFactoryBean extends LocalSlsbInvokerInter
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.beanClassLoader = classLoader; this.beanClassLoader = classLoader;
} }

View File

@ -21,6 +21,7 @@ import javax.naming.NamingException;
import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.FactoryBean;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
/** /**
@ -92,7 +93,7 @@ public class SimpleRemoteStatelessSessionProxyFactoryBean extends SimpleRemoteSl
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.beanClassLoader = classLoader; this.beanClassLoader = classLoader;
} }

View File

@ -36,6 +36,7 @@ import org.springframework.format.Formatter;
import org.springframework.format.FormatterRegistry; import org.springframework.format.FormatterRegistry;
import org.springframework.format.Parser; import org.springframework.format.Parser;
import org.springframework.format.Printer; import org.springframework.format.Printer;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.util.StringValueResolver; import org.springframework.util.StringValueResolver;
@ -145,7 +146,7 @@ public class FormattingConversionService extends GenericConversionService
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
if (source == null) { if (source == null) {
return ""; return "";
} }
@ -186,7 +187,7 @@ public class FormattingConversionService extends GenericConversionService
} }
@Override @Override
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
String text = (String) source; String text = (String) source;
if (!StringUtils.hasText(text)) { if (!StringUtils.hasText(text)) {
return null; return null;
@ -247,7 +248,7 @@ public class FormattingConversionService extends GenericConversionService
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
Annotation ann = sourceType.getAnnotation(this.annotationType); Annotation ann = sourceType.getAnnotation(this.annotationType);
if (ann == null) { if (ann == null) {
throw new IllegalStateException( throw new IllegalStateException(
@ -301,7 +302,7 @@ public class FormattingConversionService extends GenericConversionService
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
Annotation ann = targetType.getAnnotation(this.annotationType); Annotation ann = targetType.getAnnotation(this.annotationType);
if (ann == null) { if (ann == null) {
throw new IllegalStateException( throw new IllegalStateException(

View File

@ -231,7 +231,7 @@ public class MBeanClientInterceptor
} }
@Override @Override
public void setBeanClassLoader(ClassLoader beanClassLoader) { public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
this.beanClassLoader = beanClassLoader; this.beanClassLoader = beanClassLoader;
} }

View File

@ -21,6 +21,7 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.jmx.MBeanServerNotFoundException; import org.springframework.jmx.MBeanServerNotFoundException;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
/** /**
@ -67,7 +68,7 @@ public class MBeanProxyFactoryBean extends MBeanClientInterceptor
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.beanClassLoader = classLoader; this.beanClassLoader = classLoader;
} }

View File

@ -386,7 +386,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
} }
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.beanClassLoader = classLoader; this.beanClassLoader = classLoader;
} }

View File

@ -26,6 +26,7 @@ import java.util.Properties;
import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -110,7 +111,7 @@ public class InterfaceBasedMBeanInfoAssembler extends AbstractConfigurableMBeanI
} }
@Override @Override
public void setBeanClassLoader(ClassLoader beanClassLoader) { public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
this.beanClassLoader = beanClassLoader; this.beanClassLoader = beanClassLoader;
} }

Some files were not shown because too many files have changed in this diff Show More