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

@@ -33,6 +33,7 @@ import org.springframework.aop.framework.AopContext;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.support.AopUtils;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
@@ -81,7 +82,7 @@ public class MethodInvocationProceedingJoinPointTests {
private int depth;
@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();
assertTrue("Method named in toString", jp.toString().contains(method.getName()));
// Ensure that these don't cause problems
@@ -138,7 +139,7 @@ public class MethodInvocationProceedingJoinPointTests {
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
pf.addAdvice(new MethodBeforeAdvice() {
@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();
assertEquals("Same source location must be returned on subsequent requests", sloc, AbstractAspectJAdvice.currentJoinPoint().getSourceLocation());
assertEquals(TestBean.class, sloc.getWithinType());
@@ -171,7 +172,7 @@ public class MethodInvocationProceedingJoinPointTests {
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
pf.addAdvice(new MethodBeforeAdvice() {
@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();
assertEquals("Same static part must be returned on subsequent requests", staticPart, AbstractAspectJAdvice.currentJoinPoint().getStaticPart());
assertEquals(ProceedingJoinPoint.METHOD_EXECUTION, staticPart.getKind());
@@ -191,7 +192,7 @@ public class MethodInvocationProceedingJoinPointTests {
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
pf.addAdvice(new MethodBeforeAdvice() {
@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,
// it serves our purpose here
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.support.DefaultPointcutAdvisor;
import org.springframework.core.OverridingClassLoader;
import org.springframework.lang.Nullable;
import static org.junit.Assert.*;
@@ -174,7 +175,7 @@ public class TrickyAspectJPointcutExpressionTests {
private int countThrows = 0;
@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++;
}

View File

@@ -33,6 +33,7 @@ import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.aspectj.AspectJMethodBeforeAdvice;
import org.springframework.aop.aspectj.AspectJPointcutAdvisor;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.lang.Nullable;
import static org.junit.Assert.*;
@@ -196,7 +197,7 @@ public class AspectJPrecedenceComparatorTests {
private Advisor createSpringAOPAfterAdvice(int order) {
AfterReturningAdvice advice = new AfterReturningAdvice() {
@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);

View File

@@ -25,6 +25,7 @@ import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.target.EmptyTargetSource;
import org.springframework.lang.Nullable;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils;
@@ -41,7 +42,7 @@ public class AopUtilsTests {
public void testPointcutCanNeverApply() {
class TestPointcut extends StaticMethodMatcherPointcut {
@Override
public boolean matches(Method method, Class<?> clazzy) {
public boolean matches(Method method, @Nullable Class<?> clazzy) {
return false;
}
}
@@ -60,7 +61,7 @@ public class AopUtilsTests {
public void testPointcutAppliesToOneMethodOnObject() {
class TestPointcut extends StaticMethodMatcherPointcut {
@Override
public boolean matches(Method method, Class<?> clazz) {
public boolean matches(Method method, @Nullable Class<?> clazz) {
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.Pointcut;
import org.springframework.core.NestedRuntimeException;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.TestBean;
import static org.junit.Assert.*;
@@ -36,28 +37,28 @@ public class ComposablePointcutTests {
public static MethodMatcher GETTER_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, Class<?> targetClass) {
public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getName().startsWith("get");
}
};
public static MethodMatcher GET_AGE_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, Class<?> targetClass) {
public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getName().equals("getAge");
}
};
public static MethodMatcher ABSQUATULATE_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, Class<?> targetClass) {
public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getName().equals("absquatulate");
}
};
public static MethodMatcher SETTER_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, Class<?> targetClass) {
public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getName().startsWith("set");
}
};

View File

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

View File

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