Skip to content

Commit 73cf07e

Browse files
committed
Fix overridden methods nullability
Issue: SPR-15869
1 parent 6b6c1d3 commit 73cf07e

File tree

488 files changed

+1016
-34
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

488 files changed

+1016
-34
lines changed

spring-aop/src/main/java/org/springframework/aop/TargetSource.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public interface TargetSource extends TargetClassAware {
4242
* @return the type of targets returned by this {@link TargetSource}
4343
*/
4444
@Override
45+
@Nullable
4546
Class<?> getTargetClass();
4647

4748
/**

spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public void setThrowingName(@Nullable String throwingName) {
222222
* @return the parameter names
223223
*/
224224
@Override
225+
@Nullable
225226
public String[] getParameterNames(Method method) {
226227
this.argumentTypes = method.getParameterTypes();
227228
this.numberOfRemainingUnboundArguments = this.argumentTypes.length;
@@ -310,6 +311,7 @@ public String[] getParameterNames(Method method) {
310311
* {@link #setRaiseExceptions(boolean) raiseExceptions} has been set to {@code true}
311312
*/
312313
@Override
314+
@Nullable
313315
public String[] getParameterNames(Constructor<?> ctor) {
314316
if (this.raiseExceptions) {
315317
throw new UnsupportedOperationException("An advice method can never be a constructor");

spring-aop/src/main/java/org/springframework/aop/aspectj/SimpleAspectInstanceFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.springframework.aop.framework.AopConfigException;
2222
import org.springframework.core.Ordered;
23+
import org.springframework.lang.Nullable;
2324
import org.springframework.util.Assert;
2425
import org.springframework.util.ReflectionUtils;
2526

@@ -76,6 +77,7 @@ public final Object getAspectInstance() {
7677
}
7778

7879
@Override
80+
@Nullable
7981
public ClassLoader getAspectClassLoader() {
8082
return this.aspectClass.getClassLoader();
8183
}

spring-aop/src/main/java/org/springframework/aop/aspectj/SingletonAspectInstanceFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.Serializable;
2020

2121
import org.springframework.core.Ordered;
22+
import org.springframework.lang.Nullable;
2223
import org.springframework.util.Assert;
2324

2425
/**
@@ -53,6 +54,7 @@ public final Object getAspectInstance() {
5354
}
5455

5556
@Override
57+
@Nullable
5658
public ClassLoader getAspectClassLoader() {
5759
return this.aspectInstance.getClass().getClassLoader();
5860
}

spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ public String toString() {
261261
private static class AspectJAnnotationParameterNameDiscoverer implements ParameterNameDiscoverer {
262262

263263
@Override
264+
@Nullable
264265
public String[] getParameterNames(Method method) {
265266
if (method.getParameterCount() == 0) {
266267
return new String[0];
@@ -283,6 +284,7 @@ public String[] getParameterNames(Method method) {
283284
}
284285

285286
@Override
287+
@Nullable
286288
public String[] getParameterNames(Constructor<?> ctor) {
287289
throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice");
288290
}

spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectInstanceFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public Object getAspectInstance() {
9191
}
9292

9393
@Override
94+
@Nullable
9495
public ClassLoader getAspectClassLoader() {
9596
return (this.beanFactory instanceof ConfigurableBeanFactory ?
9697
((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader() :
@@ -103,6 +104,7 @@ public AspectMetadata getAspectMetadata() {
103104
}
104105

105106
@Override
107+
@Nullable
106108
public Object getAspectCreationMutex() {
107109
if (this.beanFactory.isSingleton(this.name)) {
108110
// Rely on singleton semantics provided by the factory -> no local lock.

spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/LazySingletonAspectInstanceFactoryDecorator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public boolean isMaterialized() {
7474
}
7575

7676
@Override
77+
@Nullable
7778
public ClassLoader getAspectClassLoader() {
7879
return this.maaif.getAspectClassLoader();
7980
}
@@ -84,6 +85,7 @@ public AspectMetadata getAspectMetadata() {
8485
}
8586

8687
@Override
88+
@Nullable
8789
public Object getAspectCreationMutex() {
8890
return this.maaif.getAspectCreationMutex();
8991
}

spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ private Advisor getDeclareParentsAdvisor(Field introductionField) {
184184

185185

186186
@Override
187+
@Nullable
187188
public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
188189
int declarationOrderInAspect, String aspectName) {
189190

@@ -218,6 +219,7 @@ private AspectJExpressionPointcut getPointcut(Method candidateAdviceMethod, Clas
218219

219220

220221
@Override
222+
@Nullable
221223
public Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut expressionPointcut,
222224
MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName) {
223225

spring-aop/src/main/java/org/springframework/aop/config/AdvisorComponentDefinition.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public BeanReference[] getBeanReferences() {
110110
}
111111

112112
@Override
113+
@Nullable
113114
public Object getSource() {
114115
return this.advisorDefinition.getSource();
115116
}

spring-aop/src/main/java/org/springframework/aop/config/AspectJAutoProxyBeanDefinitionParser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.beans.factory.support.ManagedList;
2626
import org.springframework.beans.factory.xml.BeanDefinitionParser;
2727
import org.springframework.beans.factory.xml.ParserContext;
28+
import org.springframework.lang.Nullable;
2829

2930
/**
3031
* {@link BeanDefinitionParser} for the {@code aspectj-autoproxy} tag,
@@ -38,6 +39,7 @@
3839
class AspectJAutoProxyBeanDefinitionParser implements BeanDefinitionParser {
3940

4041
@Override
42+
@Nullable
4143
public BeanDefinition parse(Element element, ParserContext parserContext) {
4244
AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element);
4345
extendBeanDefinition(element, parserContext);

spring-aop/src/main/java/org/springframework/aop/config/ConfigBeanDefinitionParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
9797

9898

9999
@Override
100+
@Nullable
100101
public BeanDefinition parse(Element element, ParserContext parserContext) {
101102
CompositeComponentDefinition compositeDef =
102103
new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));

spring-aop/src/main/java/org/springframework/aop/config/MethodLocatingFactoryBean.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public void setBeanFactory(BeanFactory beanFactory) {
8484

8585

8686
@Override
87+
@Nullable
8788
public Method getObject() throws Exception {
8889
return this.method;
8990
}

spring-aop/src/main/java/org/springframework/aop/config/PointcutComponentDefinition.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.springframework.beans.factory.config.BeanDefinition;
2020
import org.springframework.beans.factory.parsing.AbstractComponentDefinition;
21+
import org.springframework.lang.Nullable;
2122
import org.springframework.util.Assert;
2223

2324
/**
@@ -62,6 +63,7 @@ public BeanDefinition[] getBeanDefinitions() {
6263
}
6364

6465
@Override
66+
@Nullable
6567
public Object getSource() {
6668
return this.pointcutDefinition.getSource();
6769
}

spring-aop/src/main/java/org/springframework/aop/config/SimpleBeanFactoryAwareAspectInstanceFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public Object getAspectInstance() {
6969
}
7070

7171
@Override
72+
@Nullable
7273
public ClassLoader getAspectClassLoader() {
7374
if (this.beanFactory instanceof ConfigurableBeanFactory) {
7475
return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader();

spring-aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ public Object getObject() {
221221
}
222222

223223
@Override
224+
@Nullable
224225
public Class<?> getObjectType() {
225226
if (this.proxy != null) {
226227
return this.proxy.getClass();

spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ public void setBeanFactory(BeanFactory beanFactory) {
247247
* @return a fresh AOP proxy reflecting the current state of this factory
248248
*/
249249
@Override
250+
@Nullable
250251
public Object getObject() throws BeansException {
251252
initializeAdvisorChain();
252253
if (isSingleton()) {

spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ public void setUserAttribute(String key, @Nullable Object value) {
262262
}
263263

264264
@Override
265+
@Nullable
265266
public Object getUserAttribute(String key) {
266267
return (this.userAttributes != null ? this.userAttributes.get(key) : null);
267268
}

spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ protected BeanFactory getBeanFactory() {
218218

219219

220220
@Override
221+
@Nullable
221222
public Class<?> predictBeanType(Class<?> beanClass, String beanName) {
222223
if (this.proxyTypes.isEmpty()) {
223224
return null;
@@ -227,6 +228,7 @@ public Class<?> predictBeanType(Class<?> beanClass, String beanName) {
227228
}
228229

229230
@Override
231+
@Nullable
230232
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {
231233
return null;
232234
}

spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ protected final BeanFactory getBeanFactory() {
8989
//---------------------------------------------------------------------
9090

9191
@Override
92+
@Nullable
9293
public final TargetSource getTargetSource(Class<?> beanClass, String beanName) {
9394
AbstractBeanFactoryBasedTargetSource targetSource =
9495
createBeanFactoryBasedTargetSource(beanClass, beanName);

spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/LazyInitTargetSourceCreator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.springframework.aop.target.LazyInitTargetSource;
2121
import org.springframework.beans.factory.config.BeanDefinition;
2222
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
23+
import org.springframework.lang.Nullable;
2324

2425
/**
2526
* TargetSourceCreator that enforces a LazyInitTargetSource for each bean
@@ -59,6 +60,7 @@ protected boolean isPrototypeBased() {
5960
}
6061

6162
@Override
63+
@Nullable
6264
protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
6365
Class<?> beanClass, String beanName) {
6466

spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/QuickTargetSourceCreator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.springframework.aop.target.CommonsPool2TargetSource;
2121
import org.springframework.aop.target.PrototypeTargetSource;
2222
import org.springframework.aop.target.ThreadLocalTargetSource;
23+
import org.springframework.lang.Nullable;
2324

2425
/**
2526
* Convenient TargetSourceCreator using bean name prefixes to create one of three
@@ -41,6 +42,7 @@ public class QuickTargetSourceCreator extends AbstractBeanFactoryBasedTargetSour
4142
public static final String PREFIX_PROTOTYPE = "!";
4243

4344
@Override
45+
@Nullable
4446
protected final AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
4547
Class<?> beanClass, String beanName) {
4648

spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public Object invoke(final MethodInvocation invocation) throws Throwable {
138138
* @see #determineAsyncExecutor(Method)
139139
*/
140140
@Override
141+
@Nullable
141142
protected String getExecutorQualifier(Method method) {
142143
return null;
143144
}
@@ -151,6 +152,7 @@ protected String getExecutorQualifier(Method method) {
151152
* @see #DEFAULT_TASK_EXECUTOR_BEAN_NAME
152153
*/
153154
@Override
155+
@Nullable
154156
protected Executor getDefaultExecutor(@Nullable BeanFactory beanFactory) {
155157
Executor defaultExecutor = super.getDefaultExecutor(beanFactory);
156158
return (defaultExecutor != null ? defaultExecutor : new SimpleAsyncTaskExecutor());

spring-aop/src/main/java/org/springframework/aop/target/AbstractLazyCreationTargetSource.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.apache.commons.logging.LogFactory;
2121

2222
import org.springframework.aop.TargetSource;
23+
import org.springframework.lang.Nullable;
2324

2425
/**
2526
* {@link org.springframework.aop.TargetSource} implementation that will
@@ -65,6 +66,7 @@ public synchronized boolean isInitialized() {
6566
* @see #isInitialized()
6667
*/
6768
@Override
69+
@Nullable
6870
public synchronized Class<?> getTargetClass() {
6971
return (this.lazyTarget != null ? this.lazyTarget.getClass() : null);
7072
}

spring-aop/src/main/java/org/springframework/aop/target/AbstractPoolingTargetSource.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.springframework.beans.factory.BeanFactory;
2323
import org.springframework.beans.factory.BeanInitializationException;
2424
import org.springframework.beans.factory.DisposableBean;
25+
import org.springframework.lang.Nullable;
2526

2627
/**
2728
* Abstract base class for pooling {@link org.springframework.aop.TargetSource}
@@ -100,6 +101,7 @@ public final void setBeanFactory(BeanFactory beanFactory) throws BeansException
100101
* APIs, so we're forgiving with our exception signature
101102
*/
102103
@Override
104+
@Nullable
103105
public abstract Object getTarget() throws Exception;
104106

105107
/**

spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import org.apache.commons.pool2.impl.GenericObjectPool;
2424
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
2525

26+
import org.springframework.lang.Nullable;
27+
2628
/**
2729
* {@link org.springframework.aop.TargetSource} implementation that holds
2830
* objects in a configurable Apache Commons2 Pool.
@@ -78,6 +80,7 @@ public class CommonsPool2TargetSource extends AbstractPoolingTargetSource implem
7880
/**
7981
* The Apache Commons {@code ObjectPool} used to pool target objects
8082
*/
83+
@Nullable
8184
private ObjectPool pool;
8285

8386

spring-aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ private EmptyTargetSource(@Nullable Class<?> targetClass, boolean isStatic) {
9292
* Always returns the specified target Class, or {@code null} if none.
9393
*/
9494
@Override
95+
@Nullable
9596
public Class<?> getTargetClass() {
9697
return this.targetClass;
9798
}
@@ -108,6 +109,7 @@ public boolean isStatic() {
108109
* Always returns {@code null}.
109110
*/
110111
@Override
112+
@Nullable
111113
public Object getTarget() {
112114
return null;
113115
}

spring-aop/src/main/java/org/springframework/aop/target/LazyInitTargetSource.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.aop.target;
1818

1919
import org.springframework.beans.BeansException;
20+
import org.springframework.lang.Nullable;
2021

2122
/**
2223
* {@link org.springframework.aop.TargetSource} that lazily accesses a
@@ -59,10 +60,12 @@
5960
@SuppressWarnings("serial")
6061
public class LazyInitTargetSource extends AbstractBeanFactoryBasedTargetSource {
6162

63+
@Nullable
6264
private Object target;
6365

6466

6567
@Override
68+
@Nullable
6669
public synchronized Object getTarget() throws BeansException {
6770
if (this.target == null) {
6871
this.target = getBeanFactory().getBean(getTargetBeanName());

spring-aop/src/main/java/org/springframework/aop/target/dynamic/AbstractRefreshableTargetSource.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.apache.commons.logging.LogFactory;
2121

2222
import org.springframework.aop.TargetSource;
23+
import org.springframework.lang.Nullable;
2324

2425
/**
2526
* Abstract {@link org.springframework.aop.TargetSource} implementation that
@@ -41,6 +42,7 @@ public abstract class AbstractRefreshableTargetSource implements TargetSource, R
4142
/** Logger available to subclasses */
4243
protected final Log logger = LogFactory.getLog(getClass());
4344

45+
@Nullable
4446
protected Object targetObject;
4547

4648
private long refreshCheckDelay = -1;
@@ -80,6 +82,7 @@ public boolean isStatic() {
8082
}
8183

8284
@Override
85+
@Nullable
8386
public final synchronized Object getTarget() {
8487
if ((refreshCheckDelayElapsed() && requiresRefresh()) || this.targetObject == null) {
8588
refresh();

0 commit comments

Comments
 (0)