Fix overridden methods nullability

Issue: SPR-15869
This commit is contained in:
Sebastien Deleuze
2017-08-17 14:30:14 +02:00
parent 6b6c1d3e53
commit 73cf07e9a4
488 changed files with 1016 additions and 34 deletions

View File

@@ -42,6 +42,7 @@ public interface TargetSource extends TargetClassAware {
* @return the type of targets returned by this {@link TargetSource}
*/
@Override
@Nullable
Class<?> getTargetClass();
/**

View File

@@ -222,6 +222,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
* @return the parameter names
*/
@Override
@Nullable
public String[] getParameterNames(Method method) {
this.argumentTypes = method.getParameterTypes();
this.numberOfRemainingUnboundArguments = this.argumentTypes.length;
@@ -310,6 +311,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
* {@link #setRaiseExceptions(boolean) raiseExceptions} has been set to {@code true}
*/
@Override
@Nullable
public String[] getParameterNames(Constructor<?> ctor) {
if (this.raiseExceptions) {
throw new UnsupportedOperationException("An advice method can never be a constructor");

View File

@@ -20,6 +20,7 @@ import java.lang.reflect.InvocationTargetException;
import org.springframework.aop.framework.AopConfigException;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
@@ -76,6 +77,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
}
@Override
@Nullable
public ClassLoader getAspectClassLoader() {
return this.aspectClass.getClassLoader();
}

View File

@@ -19,6 +19,7 @@ package org.springframework.aop.aspectj;
import java.io.Serializable;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -53,6 +54,7 @@ public class SingletonAspectInstanceFactory implements AspectInstanceFactory, Se
}
@Override
@Nullable
public ClassLoader getAspectClassLoader() {
return this.aspectInstance.getClass().getClassLoader();
}

View File

@@ -261,6 +261,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
private static class AspectJAnnotationParameterNameDiscoverer implements ParameterNameDiscoverer {
@Override
@Nullable
public String[] getParameterNames(Method method) {
if (method.getParameterCount() == 0) {
return new String[0];
@@ -283,6 +284,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
}
@Override
@Nullable
public String[] getParameterNames(Constructor<?> ctor) {
throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice");
}

View File

@@ -91,6 +91,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
}
@Override
@Nullable
public ClassLoader getAspectClassLoader() {
return (this.beanFactory instanceof ConfigurableBeanFactory ?
((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader() :
@@ -103,6 +104,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
}
@Override
@Nullable
public Object getAspectCreationMutex() {
if (this.beanFactory.isSingleton(this.name)) {
// Rely on singleton semantics provided by the factory -> no local lock.

View File

@@ -74,6 +74,7 @@ public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwar
}
@Override
@Nullable
public ClassLoader getAspectClassLoader() {
return this.maaif.getAspectClassLoader();
}
@@ -84,6 +85,7 @@ public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwar
}
@Override
@Nullable
public Object getAspectCreationMutex() {
return this.maaif.getAspectCreationMutex();
}

View File

@@ -184,6 +184,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
@Override
@Nullable
public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
int declarationOrderInAspect, String aspectName) {
@@ -218,6 +219,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
@Override
@Nullable
public Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut expressionPointcut,
MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName) {

View File

@@ -110,6 +110,7 @@ public class AdvisorComponentDefinition extends AbstractComponentDefinition {
}
@Override
@Nullable
public Object getSource() {
return this.advisorDefinition.getSource();
}

View File

@@ -25,6 +25,7 @@ import org.springframework.beans.factory.config.TypedStringValue;
import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.lang.Nullable;
/**
* {@link BeanDefinitionParser} for the {@code aspectj-autoproxy} tag,
@@ -38,6 +39,7 @@ import org.springframework.beans.factory.xml.ParserContext;
class AspectJAutoProxyBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element);
extendBeanDefinition(element, parserContext);

View File

@@ -97,6 +97,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
CompositeComponentDefinition compositeDef =
new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));

View File

@@ -84,6 +84,7 @@ public class MethodLocatingFactoryBean implements FactoryBean<Method>, BeanFacto
@Override
@Nullable
public Method getObject() throws Exception {
return this.method;
}

View File

@@ -18,6 +18,7 @@ package org.springframework.aop.config;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.parsing.AbstractComponentDefinition;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -62,6 +63,7 @@ public class PointcutComponentDefinition extends AbstractComponentDefinition {
}
@Override
@Nullable
public Object getSource() {
return this.pointcutDefinition.getSource();
}

View File

@@ -69,6 +69,7 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan
}
@Override
@Nullable
public ClassLoader getAspectClassLoader() {
if (this.beanFactory instanceof ConfigurableBeanFactory) {
return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader();

View File

@@ -221,6 +221,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
}
@Override
@Nullable
public Class<?> getObjectType() {
if (this.proxy != null) {
return this.proxy.getClass();

View File

@@ -247,6 +247,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
* @return a fresh AOP proxy reflecting the current state of this factory
*/
@Override
@Nullable
public Object getObject() throws BeansException {
initializeAdvisorChain();
if (isSingleton()) {

View File

@@ -262,6 +262,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
}
@Override
@Nullable
public Object getUserAttribute(String key) {
return (this.userAttributes != null ? this.userAttributes.get(key) : null);
}

View File

@@ -218,6 +218,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
@Override
@Nullable
public Class<?> predictBeanType(Class<?> beanClass, String beanName) {
if (this.proxyTypes.isEmpty()) {
return null;
@@ -227,6 +228,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
}
@Override
@Nullable
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {
return null;
}

View File

@@ -89,6 +89,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
//---------------------------------------------------------------------
@Override
@Nullable
public final TargetSource getTargetSource(Class<?> beanClass, String beanName) {
AbstractBeanFactoryBasedTargetSource targetSource =
createBeanFactoryBasedTargetSource(beanClass, beanName);

View File

@@ -20,6 +20,7 @@ import org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource;
import org.springframework.aop.target.LazyInitTargetSource;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.lang.Nullable;
/**
* TargetSourceCreator that enforces a LazyInitTargetSource for each bean
@@ -59,6 +60,7 @@ public class LazyInitTargetSourceCreator extends AbstractBeanFactoryBasedTargetS
}
@Override
@Nullable
protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
Class<?> beanClass, String beanName) {

View File

@@ -20,6 +20,7 @@ import org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource;
import org.springframework.aop.target.CommonsPool2TargetSource;
import org.springframework.aop.target.PrototypeTargetSource;
import org.springframework.aop.target.ThreadLocalTargetSource;
import org.springframework.lang.Nullable;
/**
* Convenient TargetSourceCreator using bean name prefixes to create one of three
@@ -41,6 +42,7 @@ public class QuickTargetSourceCreator extends AbstractBeanFactoryBasedTargetSour
public static final String PREFIX_PROTOTYPE = "!";
@Override
@Nullable
protected final AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
Class<?> beanClass, String beanName) {

View File

@@ -138,6 +138,7 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport imple
* @see #determineAsyncExecutor(Method)
*/
@Override
@Nullable
protected String getExecutorQualifier(Method method) {
return null;
}
@@ -151,6 +152,7 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport imple
* @see #DEFAULT_TASK_EXECUTOR_BEAN_NAME
*/
@Override
@Nullable
protected Executor getDefaultExecutor(@Nullable BeanFactory beanFactory) {
Executor defaultExecutor = super.getDefaultExecutor(beanFactory);
return (defaultExecutor != null ? defaultExecutor : new SimpleAsyncTaskExecutor());

View File

@@ -20,6 +20,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.TargetSource;
import org.springframework.lang.Nullable;
/**
* {@link org.springframework.aop.TargetSource} implementation that will
@@ -65,6 +66,7 @@ public abstract class AbstractLazyCreationTargetSource implements TargetSource {
* @see #isInitialized()
*/
@Override
@Nullable
public synchronized Class<?> getTargetClass() {
return (this.lazyTarget != null ? this.lazyTarget.getClass() : null);
}

View File

@@ -22,6 +22,7 @@ import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.lang.Nullable;
/**
* Abstract base class for pooling {@link org.springframework.aop.TargetSource}
@@ -100,6 +101,7 @@ public abstract class AbstractPoolingTargetSource extends AbstractPrototypeBased
* APIs, so we're forgiving with our exception signature
*/
@Override
@Nullable
public abstract Object getTarget() throws Exception;
/**

View File

@@ -23,6 +23,8 @@ import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.lang.Nullable;
/**
* {@link org.springframework.aop.TargetSource} implementation that holds
* objects in a configurable Apache Commons2 Pool.
@@ -78,6 +80,7 @@ public class CommonsPool2TargetSource extends AbstractPoolingTargetSource implem
/**
* The Apache Commons {@code ObjectPool} used to pool target objects
*/
@Nullable
private ObjectPool pool;

View File

@@ -92,6 +92,7 @@ public class EmptyTargetSource implements TargetSource, Serializable {
* Always returns the specified target Class, or {@code null} if none.
*/
@Override
@Nullable
public Class<?> getTargetClass() {
return this.targetClass;
}
@@ -108,6 +109,7 @@ public class EmptyTargetSource implements TargetSource, Serializable {
* Always returns {@code null}.
*/
@Override
@Nullable
public Object getTarget() {
return null;
}

View File

@@ -17,6 +17,7 @@
package org.springframework.aop.target;
import org.springframework.beans.BeansException;
import org.springframework.lang.Nullable;
/**
* {@link org.springframework.aop.TargetSource} that lazily accesses a
@@ -59,10 +60,12 @@ import org.springframework.beans.BeansException;
@SuppressWarnings("serial")
public class LazyInitTargetSource extends AbstractBeanFactoryBasedTargetSource {
@Nullable
private Object target;
@Override
@Nullable
public synchronized Object getTarget() throws BeansException {
if (this.target == null) {
this.target = getBeanFactory().getBean(getTargetBeanName());

View File

@@ -20,6 +20,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.TargetSource;
import org.springframework.lang.Nullable;
/**
* Abstract {@link org.springframework.aop.TargetSource} implementation that
@@ -41,6 +42,7 @@ public abstract class AbstractRefreshableTargetSource implements TargetSource, R
/** Logger available to subclasses */
protected final Log logger = LogFactory.getLog(getClass());
@Nullable
protected Object targetObject;
private long refreshCheckDelay = -1;
@@ -80,6 +82,7 @@ public abstract class AbstractRefreshableTargetSource implements TargetSource, R
}
@Override
@Nullable
public final synchronized Object getTarget() {
if ((refreshCheckDelayElapsed() && requiresRefresh()) || this.targetObject == null) {
refresh();

View File

@@ -1,15 +0,0 @@
<html>
<body>
This package contains implementations of the org.springframework.aop.TargetSource interface.
<br>
The simplest implementation is the SingletonTargetSource, used by default in the AOP framework
to wrap a single target instance. This is normally appropriate.
<br>
Other provided implementations include pooling implementations, that provide a target
from a pool for each request, ensuring a single threaded programming model; and a
"prototype" implementation, that uses a new target instance for each invocation.
</body>
</html>

View File

@@ -483,6 +483,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
}
@Override
@Nullable
public Class<?> getPropertyType(String propertyName) throws BeansException {
try {
PropertyHandler ph = getPropertyHandler(propertyName);
@@ -510,6 +511,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
}
@Override
@Nullable
public TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException {
try {
AbstractNestablePropertyAccessor nestedPa = getPropertyAccessorForPropertyPath(propertyName);
@@ -603,6 +605,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
}
@Override
@Nullable
public Object getPropertyValue(String propertyName) throws BeansException {
AbstractNestablePropertyAccessor nestedPa = getPropertyAccessorForPropertyPath(propertyName);
PropertyTokenHolder tokens = getPropertyNameTokens(getFinalPath(nestedPa, propertyName));

View File

@@ -127,6 +127,7 @@ public abstract class AbstractPropertyAccessor extends TypeConverterSupport impl
// Redefined with public visibility.
@Override
@Nullable
public Class<?> getPropertyType(String propertyPath) {
return null;
}
@@ -141,6 +142,7 @@ public abstract class AbstractPropertyAccessor extends TypeConverterSupport impl
* accessor method failed
*/
@Override
@Nullable
public abstract Object getPropertyValue(String propertyName) throws BeansException;
/**

View File

@@ -74,12 +74,14 @@ public class BeanMetadataAttributeAccessor extends AttributeAccessorSupport impl
}
@Override
@Nullable
public Object getAttribute(String name) {
BeanMetadataAttribute attribute = (BeanMetadataAttribute) super.getAttribute(name);
return (attribute != null ? attribute.getValue() : null);
}
@Override
@Nullable
public Object removeAttribute(String name) {
BeanMetadataAttribute attribute = (BeanMetadataAttribute) super.removeAttribute(name);
return (attribute != null ? attribute.getValue() : null);

View File

@@ -225,6 +225,7 @@ public class BeanWrapperImpl extends AbstractNestablePropertyAccessor implements
}
@Override
@Nullable
protected BeanPropertyHandler getLocalPropertyHandler(String propertyName) {
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(propertyName);
if (pd != null) {
@@ -284,11 +285,13 @@ public class BeanWrapperImpl extends AbstractNestablePropertyAccessor implements
}
@Override
@Nullable
public TypeDescriptor nested(int level) {
return TypeDescriptor.nested(property(pd), level);
}
@Override
@Nullable
public Object getValue() throws Exception {
final Method readMethod = this.pd.getReadMethod();
if (System.getSecurityManager() != null) {

View File

@@ -117,11 +117,13 @@ public class DirectFieldAccessor extends AbstractNestablePropertyAccessor {
}
@Override
@Nullable
public TypeDescriptor nested(int level) {
return TypeDescriptor.nested(this.field, level);
}
@Override
@Nullable
public Object getValue() throws Exception {
try {
ReflectionUtils.makeAccessible(this.field);

View File

@@ -22,6 +22,7 @@ import java.beans.Introspector;
import java.lang.reflect.Method;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
/**
* {@link BeanInfoFactory} implementation that evaluates whether bean classes have
@@ -42,6 +43,7 @@ public class ExtendedBeanInfoFactory implements BeanInfoFactory, Ordered {
* Return an {@link ExtendedBeanInfo} for the given bean class, if applicable.
*/
@Override
@Nullable
public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
return (supports(beanClass) ? new ExtendedBeanInfo(Introspector.getBeanInfo(beanClass)) : null);
}

View File

@@ -250,6 +250,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
}
@Override
@Nullable
public PropertyValue getPropertyValue(String propertyName) {
for (PropertyValue pv : this.propertyValueList) {
if (pv.getName().equals(propertyName)) {

View File

@@ -39,11 +39,13 @@ public abstract class TypeConverterSupport extends PropertyEditorRegistrySupport
@Override
@Nullable
public <T> T convertIfNecessary(@Nullable Object value, @Nullable Class<T> requiredType) throws TypeMismatchException {
return doConvert(value, requiredType, null, null);
}
@Override
@Nullable
public <T> T convertIfNecessary(@Nullable Object value, @Nullable Class<T> requiredType, @Nullable MethodParameter methodParam)
throws TypeMismatchException {
@@ -51,6 +53,7 @@ public abstract class TypeConverterSupport extends PropertyEditorRegistrySupport
}
@Override
@Nullable
public <T> T convertIfNecessary(@Nullable Object value, @Nullable Class<T> requiredType, @Nullable Field field)
throws TypeMismatchException {

View File

@@ -18,6 +18,7 @@ package org.springframework.beans.factory.annotation;
import org.springframework.beans.factory.wiring.BeanWiringInfo;
import org.springframework.beans.factory.wiring.BeanWiringInfoResolver;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -37,6 +38,7 @@ import org.springframework.util.ClassUtils;
public class AnnotationBeanWiringInfoResolver implements BeanWiringInfoResolver {
@Override
@Nullable
public BeanWiringInfo resolveWiringInfo(Object beanInstance) {
Assert.notNull(beanInstance, "Bean instance must not be null");
Configurable annotation = beanInstance.getClass().getAnnotation(Configurable.class);

View File

@@ -234,6 +234,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
}
@Override
@Nullable
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, final String beanName)
throws BeanCreationException {

View File

@@ -330,6 +330,7 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
* @see Value
*/
@Override
@Nullable
public Object getSuggestedValue(DependencyDescriptor descriptor) {
Object value = findValue(descriptor.getAnnotations());
if (value == null) {

View File

@@ -206,6 +206,7 @@ public abstract class AbstractFactoryBean<T>
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
*/
@Override
@Nullable
public abstract Class<?> getObjectType();
/**

View File

@@ -113,6 +113,7 @@ public class BeanDefinitionHolder implements BeanMetadataElement {
* @see BeanDefinition#getSource()
*/
@Override
@Nullable
public Object getSource() {
return this.beanDefinition.getSource();
}

View File

@@ -49,6 +49,7 @@ public class EmbeddedValueResolver implements StringValueResolver {
@Override
@Nullable
public String resolveStringValue(String strVal) {
String value = this.exprContext.getBeanFactory().resolveEmbeddedValue(strVal);
if (this.exprResolver != null && value != null) {

View File

@@ -208,6 +208,7 @@ public class FieldRetrievingFactoryBean
@Override
@Nullable
public Object getObject() throws IllegalAccessException {
if (this.fieldObject == null) {
throw new FactoryBeanNotInitializedException();

View File

@@ -21,6 +21,7 @@ import java.lang.reflect.Constructor;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.lang.Nullable;
/**
* Adapter that implements all methods on {@link SmartInstantiationAwareBeanPostProcessor}
@@ -40,11 +41,13 @@ import org.springframework.beans.PropertyValues;
public abstract class InstantiationAwareBeanPostProcessorAdapter implements SmartInstantiationAwareBeanPostProcessor {
@Override
@Nullable
public Class<?> predictBeanType(Class<?> beanClass, String beanName) {
return null;
}
@Override
@Nullable
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {
return null;
}
@@ -55,6 +58,7 @@ public abstract class InstantiationAwareBeanPostProcessorAdapter implements Smar
}
@Override
@Nullable
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
return null;
}

View File

@@ -116,6 +116,7 @@ public class MethodInvokingFactoryBean extends MethodInvokingBean implements Fac
* specified method on the fly.
*/
@Override
@Nullable
public Object getObject() throws Exception {
if (this.singleton) {
if (!this.initialized) {

View File

@@ -75,6 +75,7 @@ public class PropertiesFactoryBean extends PropertiesLoaderSupport
}
@Override
@Nullable
public final Properties getObject() throws IOException {
if (this.singleton) {
return this.singletonInstance;

View File

@@ -201,6 +201,7 @@ public class PropertyPathFactoryBean implements FactoryBean<Object>, BeanNameAwa
@Override
@Nullable
public Object getObject() throws BeansException {
BeanWrapper target = this.targetBeanWrapper;
if (target != null) {

View File

@@ -239,6 +239,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
}
@Override
@Nullable
public String resolveStringValue(String strVal) throws BeansException {
String resolved = this.helper.replacePlaceholders(strVal, this.resolver);
if (trimValues) {
@@ -258,6 +259,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
}
@Override
@Nullable
public String resolvePlaceholder(String placeholderName) {
return PropertyPlaceholderConfigurer.this.resolvePlaceholder(placeholderName, props, systemPropertiesMode);
}

View File

@@ -329,6 +329,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
@Override
@Nullable
public Object getObject() {
return this.proxy;
}

View File

@@ -97,6 +97,7 @@ public class YamlMapFactoryBean extends YamlProcessor implements FactoryBean<Map
}
@Override
@Nullable
public Map<String, Object> getObject() {
return (this.map != null ? this.map : createMap());
}

View File

@@ -108,6 +108,7 @@ public class YamlPropertiesFactoryBean extends YamlProcessor implements FactoryB
}
@Override
@Nullable
public Properties getObject() {
return (this.properties != null ? this.properties : createProperties());
}

View File

@@ -20,6 +20,7 @@ import java.util.Iterator;
import java.util.ServiceLoader;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.lang.Nullable;
/**
* {@link org.springframework.beans.factory.FactoryBean} that exposes the
@@ -43,6 +44,7 @@ public class ServiceFactoryBean extends AbstractServiceLoaderBasedFactoryBean im
}
@Override
@Nullable
public Class<?> getObjectType() {
return getServiceType();
}

View File

@@ -340,6 +340,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
}
@Override
@Nullable
public Object resolveDependency(DependencyDescriptor descriptor, @Nullable String requestingBeanName) throws BeansException {
return resolveDependency(descriptor, requestingBeanName, null, null);
}
@@ -409,11 +410,13 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
}
@Override
@Nullable
public Object initializeBean(Object existingBean, String beanName) {
return initializeBean(beanName, existingBean, null);
}
@Override
@Nullable
public Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName)
throws BeansException {
@@ -428,6 +431,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
}
@Override
@Nullable
public Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName)
throws BeansException {
@@ -457,6 +461,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @see #doCreateBean
*/
@Override
@Nullable
protected Object createBean(String beanName, RootBeanDefinition mbd, @Nullable Object[] args)
throws BeanCreationException {
@@ -634,6 +639,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
}
@Override
@Nullable
protected Class<?> predictBeanType(String beanName, RootBeanDefinition mbd, Class<?>... typesToMatch) {
Class<?> targetType = determineTargetType(beanName, mbd, typesToMatch);
@@ -800,6 +806,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* it will be fully created to check the type of its exposed object.
*/
@Override
@Nullable
protected Class<?> getTypeForFactoryBean(String beanName, RootBeanDefinition mbd) {
String factoryBeanName = mbd.getFactoryBeanName();
String factoryMethodName = mbd.getFactoryMethodName();
@@ -1177,6 +1184,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @see #obtainFromSupplier
*/
@Override
@Nullable
protected Object getObjectForBeanInstance(
@Nullable Object beanInstance, String name, String beanName, @Nullable RootBeanDefinition mbd) {

View File

@@ -358,6 +358,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
* Return the current bean class name of this bean definition.
*/
@Override
@Nullable
public String getBeanClassName() {
Object beanClassObject = this.beanClass;
if (beanClassObject instanceof Class) {
@@ -971,6 +972,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
* came from (for the purpose of showing context in case of errors).
*/
@Override
@Nullable
public String getResourceDescription() {
return (this.resource != null ? this.resource.getDescription() : null);
}
@@ -989,6 +991,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
* originator chain to find the original BeanDefinition as defined by the user.
*/
@Override
@Nullable
public BeanDefinition getOriginatingBeanDefinition() {
return (this.resource instanceof BeanDefinitionResource ?
((BeanDefinitionResource) this.resource).getBeanDefinition() : null);

View File

@@ -599,6 +599,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
}
@Override
@Nullable
public Class<?> getType(String name) throws NoSuchBeanDefinitionException {
String beanName = transformedBeanName(name);
@@ -840,6 +841,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
}
@Override
@Nullable
public String resolveEmbeddedValue(@Nullable String value) {
if (value == null) {
return null;
@@ -926,6 +928,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
}
@Override
@Nullable
public Scope getRegisteredScope(String scopeName) {
Assert.notNull(scopeName, "Scope identifier must not be null");
return this.scopes.get(scopeName);

View File

@@ -570,6 +570,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
* if not found on the exposed bean reference (e.g. in case of a proxy).
*/
@Override
@Nullable
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
throws NoSuchBeanDefinitionException{
@@ -1037,6 +1038,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
}
@Override
@Nullable
public Object resolveDependency(DependencyDescriptor descriptor, @Nullable String requestingBeanName,
@Nullable Set<String> autowiredBeanNames, @Nullable TypeConverter typeConverter) throws BeansException {
@@ -1613,6 +1615,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
}
@Override
@Nullable
public Object getObject() throws BeansException {
if (this.optional) {
return createOptionalDependency(this.descriptor, this.beanName);
@@ -1623,6 +1626,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
}
@Override
@Nullable
public Object getObject(final Object... args) throws BeansException {
if (this.optional) {
return createOptionalDependency(this.descriptor, this.beanName, args);
@@ -1639,6 +1643,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
}
@Override
@Nullable
public Object getIfAvailable() throws BeansException {
if (this.optional) {
return createOptionalDependency(this.descriptor, this.beanName);
@@ -1655,6 +1660,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
}
@Override
@Nullable
public Object getIfUnique() throws BeansException {
DependencyDescriptor descriptorToUse = new DependencyDescriptor(descriptor) {
@Override
@@ -1662,6 +1668,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
return false;
}
@Override
@Nullable
public Object resolveNotUnique(Class<?> type, Map<String, Object> matchingBeans) {
return null;
}
@@ -1720,6 +1727,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
}
@Override
@Nullable
public Object getOrderSource(Object obj) {
RootBeanDefinition beanDefinition = getRootBeanDefinition(this.instancesToBeanNames.get(obj));
if (beanDefinition == null) {

View File

@@ -171,6 +171,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
}
@Override
@Nullable
public Object getSingleton(String beanName) {
return getSingleton(beanName, true);
}

View File

@@ -41,11 +41,13 @@ public class SimpleAutowireCandidateResolver implements AutowireCandidateResolve
}
@Override
@Nullable
public Object getSuggestedValue(DependencyDescriptor descriptor) {
return null;
}
@Override
@Nullable
public Object getLazyResolutionProxyIfNecessary(DependencyDescriptor descriptor, @Nullable String beanName) {
return null;
}

View File

@@ -355,6 +355,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
}
@Override
@Nullable
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
throws NoSuchBeanDefinitionException{

View File

@@ -58,6 +58,7 @@ public abstract class AbstractBeanDefinitionParser implements BeanDefinitionPars
@Override
@Nullable
public final BeanDefinition parse(Element element, ParserContext parserContext) {
AbstractBeanDefinition definition = parseInternal(element, parserContext);
if (definition != null && !parserContext.isNested()) {

View File

@@ -113,6 +113,7 @@ public class DefaultNamespaceHandlerResolver implements NamespaceHandlerResolver
* @return the located {@link NamespaceHandler}, or {@code null} if none found
*/
@Override
@Nullable
public NamespaceHandler resolve(String namespaceUri) {
Map<String, Object> handlerMappings = getHandlerMappings();
Object handlerOrClassName = handlerMappings.get(namespaceUri);

View File

@@ -68,6 +68,7 @@ public abstract class NamespaceHandlerSupport implements NamespaceHandler {
* registered for that {@link Element}.
*/
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
BeanDefinitionParser parser = findParserForElement(element, parserContext);
return (parser != null ? parser.parse(element, parserContext) : null);
@@ -93,6 +94,7 @@ public abstract class NamespaceHandlerSupport implements NamespaceHandler {
* is registered to handle that {@link Node}.
*/
@Override
@Nullable
public BeanDefinitionHolder decorate(
Node node, BeanDefinitionHolder definition, ParserContext parserContext) {

View File

@@ -71,6 +71,7 @@ public class ResourceEntityResolver extends DelegatingEntityResolver {
@Override
@Nullable
public InputSource resolveEntity(String publicId, @Nullable String systemId) throws SAXException, IOException {
InputSource source = super.resolveEntity(publicId, systemId);
if (source == null && systemId != null) {

View File

@@ -28,6 +28,7 @@ import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.core.Conventions;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
/**
@@ -68,6 +69,7 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
}
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
parserContext.getReaderContext().error(
"Class [" + getClass().getName() + "] does not support custom elements.", element);

View File

@@ -25,6 +25,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.core.Conventions;
import org.springframework.lang.Nullable;
/**
* Simple {@code NamespaceHandler} implementation that maps custom attributes
@@ -57,6 +58,7 @@ public class SimplePropertyNamespaceHandler implements NamespaceHandler {
}
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
parserContext.getReaderContext().error(
"Class [" + getClass().getName() + "] does not support custom elements.", element);

View File

@@ -83,6 +83,7 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
}
@Override
@Nullable
public ValueWrapper get(Object key) {
if (this.cache instanceof LoadingCache) {
Object value = ((LoadingCache<Object, Object>) this.cache).get(key);

View File

@@ -176,6 +176,7 @@ public class CaffeineCacheManager implements CacheManager {
}
@Override
@Nullable
public Cache getCache(String name) {
Cache cache = this.cacheMap.get(name);
if (cache == null && this.dynamic) {

View File

@@ -64,6 +64,7 @@ public class EhCacheCache implements Cache {
}
@Override
@Nullable
public ValueWrapper get(Object key) {
Element element = lookup(key);
return toValueWrapper(element);
@@ -125,6 +126,7 @@ public class EhCacheCache implements Cache {
}
@Override
@Nullable
public ValueWrapper putIfAbsent(Object key, @Nullable Object value) {
Element existingElement = this.cache.putIfAbsent(new Element(key, value));
return toValueWrapper(existingElement);

View File

@@ -287,6 +287,7 @@ public class EhCacheFactoryBean extends CacheConfiguration implements FactoryBea
@Override
@Nullable
public Ehcache getObject() {
return this.cache;
}

View File

@@ -169,6 +169,7 @@ public class EhCacheManagerFactoryBean implements FactoryBean<CacheManager>, Ini
@Override
@Nullable
public CacheManager getObject() {
return this.cacheManager;
}

View File

@@ -76,6 +76,7 @@ public class JCacheCache extends AbstractValueAdaptingCache {
}
@Override
@Nullable
public <T> T get(Object key, Callable<T> valueLoader) {
try {
return this.cache.invoke(key, new ValueLoaderEntryProcessor<T>(), valueLoader);
@@ -91,6 +92,7 @@ public class JCacheCache extends AbstractValueAdaptingCache {
}
@Override
@Nullable
public ValueWrapper putIfAbsent(Object key, @Nullable Object value) {
boolean set = this.cache.putIfAbsent(key, toStoreValue(value));
return (set ? null : get(key));

View File

@@ -85,6 +85,7 @@ public class JCacheManagerFactoryBean
@Override
@Nullable
public CacheManager getObject() {
return this.cacheManager;
}

View File

@@ -72,6 +72,7 @@ public class TransactionAwareCacheDecorator implements Cache {
}
@Override
@Nullable
public ValueWrapper get(Object key) {
return this.targetCache.get(key);
}
@@ -82,6 +83,7 @@ public class TransactionAwareCacheDecorator implements Cache {
}
@Override
@Nullable
public <T> T get(Object key, Callable<T> valueLoader) {
return this.targetCache.get(key, valueLoader);
}
@@ -102,6 +104,7 @@ public class TransactionAwareCacheDecorator implements Cache {
}
@Override
@Nullable
public ValueWrapper putIfAbsent(Object key, @Nullable Object value) {
return this.targetCache.putIfAbsent(key, value);
}

View File

@@ -76,6 +76,7 @@ public class TransactionAwareCacheManagerProxy implements CacheManager, Initiali
@Override
@Nullable
public Cache getCache(String name) {
Assert.state(this.targetCacheManager != null, "No target CacheManager set");
Cache targetCache = this.targetCacheManager.getCache(name);

View File

@@ -123,6 +123,7 @@ public class MailSendException extends MailException {
@Override
@Nullable
public String getMessage() {
if (ObjectUtils.isEmpty(this.messageExceptions)) {
return super.getMessage();

View File

@@ -110,6 +110,7 @@ public class TimerManagerFactoryBean extends TimerManagerAccessor
//---------------------------------------------------------------------
@Override
@Nullable
public TimerManager getObject() {
return getTimerManager();
}

View File

@@ -56,6 +56,7 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T
@Override
@Nullable
public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
return new ReschedulingTimerListener(errorHandlingTask(task, true), trigger).schedule();
}

View File

@@ -266,6 +266,7 @@ public class CronTriggerFactoryBean implements FactoryBean<CronTrigger>, BeanNam
@Override
@Nullable
public CronTrigger getObject() {
return this.cronTrigger;
}

View File

@@ -218,6 +218,7 @@ public class JobDetailFactoryBean
@Override
@Nullable
public JobDetail getObject() {
return this.jobDetail;
}

View File

@@ -223,6 +223,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
@Override
@Nullable
public JobDetail getObject() {
return this.jobDetail;
}

View File

@@ -708,6 +708,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
}
@Override
@Nullable
public Scheduler getObject() {
return this.scheduler;
}

View File

@@ -251,6 +251,7 @@ public class SimpleTriggerFactoryBean implements FactoryBean<SimpleTrigger>, Bea
@Override
@Nullable
public SimpleTrigger getObject() {
return this.simpleTrigger;
}

View File

@@ -65,6 +65,7 @@ public class FreeMarkerConfigurationFactoryBean extends FreeMarkerConfigurationF
@Override
@Nullable
public Configuration getObject() {
return this.configuration;
}

View File

@@ -157,7 +157,8 @@ public interface Cache {
/**
* Return the actual value in the cache.
*/
@Nullable Object get();
@Nullable
Object get();
}

View File

@@ -106,11 +106,13 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati
@Override
@Nullable
protected Collection<CacheOperation> findCacheOperations(final Class<?> clazz) {
return determineCacheOperations(parser -> parser.parseCacheAnnotations(clazz));
}
@Override
@Nullable
protected Collection<CacheOperation> findCacheOperations(final Method method) {
return determineCacheOperations(parser -> parser.parseCacheAnnotations(method));
}

View File

@@ -20,6 +20,7 @@ import org.springframework.cache.CacheManager;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.CacheResolver;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.lang.Nullable;
/**
* An implementation of {@link CachingConfigurer} with empty methods allowing
@@ -32,21 +33,25 @@ import org.springframework.cache.interceptor.KeyGenerator;
public class CachingConfigurerSupport implements CachingConfigurer {
@Override
@Nullable
public CacheManager cacheManager() {
return null;
}
@Override
@Nullable
public KeyGenerator keyGenerator() {
return null;
}
@Override
@Nullable
public CacheResolver cacheResolver() {
return null;
}
@Override
@Nullable
public CacheErrorHandler errorHandler() {
return null;
}

View File

@@ -48,12 +48,14 @@ import org.springframework.util.StringUtils;
public class SpringCacheAnnotationParser implements CacheAnnotationParser, Serializable {
@Override
@Nullable
public Collection<CacheOperation> parseCacheAnnotations(Class<?> type) {
DefaultCacheConfig defaultConfig = getDefaultCacheConfig(type);
return parseCacheAnnotations(defaultConfig, type);
}
@Override
@Nullable
public Collection<CacheOperation> parseCacheAnnotations(Method method) {
DefaultCacheConfig defaultConfig = getDefaultCacheConfig(method.getDeclaringClass());
return parseCacheAnnotations(defaultConfig, method);

View File

@@ -92,6 +92,7 @@ public class ConcurrentMapCacheFactoryBean
@Override
@Nullable
public ConcurrentMapCache getObject() {
return this.cache;
}

View File

@@ -162,6 +162,7 @@ public class ConcurrentMapCacheManager implements CacheManager, BeanClassLoaderA
}
@Override
@Nullable
public Cache getCache(String name) {
Cache cache = this.cacheMap.get(name);
if (cache == null && this.dynamic) {

View File

@@ -75,6 +75,7 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser
* register an AutoProxyCreator} with the container as necessary.
*/
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
String mode = element.getAttribute("mode");
if ("aspectj".equals(mode)) {

View File

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

View File

@@ -36,6 +36,7 @@ public class BeanFactoryCacheOperationSourceAdvisor extends AbstractBeanFactoryP
private final CacheOperationSourcePointcut pointcut = new CacheOperationSourcePointcut() {
@Override
@Nullable
protected CacheOperationSource getCacheOperationSource() {
return cacheOperationSource;
}

View File

@@ -22,6 +22,7 @@ import java.util.Set;
import org.springframework.context.expression.MethodBasedEvaluationContext;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.lang.Nullable;
/**
* Cache specific evaluation context that adds a method parameters as SpEL
@@ -69,6 +70,7 @@ class CacheEvaluationContext extends MethodBasedEvaluationContext {
* Load the param information only when needed.
*/
@Override
@Nullable
public Object lookupVariable(String name) {
if (this.unavailableVariables.contains(name)) {
throw new VariableNotAvailableException(name);

View File

@@ -55,6 +55,7 @@ public class CompositeCacheOperationSource implements CacheOperationSource, Seri
}
@Override
@Nullable
public Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass) {
Collection<CacheOperation> ops = null;

View File

@@ -75,6 +75,7 @@ public class NameMatchCacheOperationSource implements CacheOperationSource, Seri
}
@Override
@Nullable
public Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass) {
// look for direct name match
String methodName = method.getName();

View File

@@ -85,6 +85,7 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing
// Lazy cache initialization on access
@Override
@Nullable
public Cache getCache(String name) {
Cache cache = this.cacheMap.get(name);
if (cache != null) {

View File

@@ -27,6 +27,7 @@ import java.util.Set;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.lang.Nullable;
/**
* Composite {@link CacheManager} implementation that iterates over
@@ -98,6 +99,7 @@ public class CompositeCacheManager implements CacheManager, InitializingBean {
@Override
@Nullable
public Cache getCache(String name) {
for (CacheManager cacheManager : this.cacheManagers) {
Cache cache = cacheManager.getCache(name);

View File

@@ -58,16 +58,19 @@ public class NoOpCache implements Cache {
}
@Override
@Nullable
public ValueWrapper get(Object key) {
return null;
}
@Override
@Nullable
public <T> T get(Object key, @Nullable Class<T> type) {
return null;
}
@Override
@Nullable
public <T> T get(Object key, Callable<T> valueLoader) {
try {
return valueLoader.call();

View File

@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentMap;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.lang.Nullable;
/**
* A basic, no operation {@link CacheManager} implementation suitable
@@ -50,6 +51,7 @@ public class NoOpCacheManager implements CacheManager {
* Additionally, the request cache will be remembered by the manager for consistency.
*/
@Override
@Nullable
public Cache getCache(String name) {
Cache cache = this.caches.get(name);
if (cache == null) {

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