Perform NullAway build-time checks in more modules
This commit enables null-safety build-time checks in: - spring-jdbc - spring-r2dbc - spring-orm - spring-beans - spring-aop See gh-32475
This commit is contained in:
@@ -552,6 +552,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
* @param ex the exception thrown by the method execution (may be null)
|
||||
* @return the empty array if there are no arguments
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
protected Object[] argBinding(JoinPoint jp, @Nullable JoinPointMatch jpMatch,
|
||||
@Nullable Object returnValue, @Nullable Throwable ex) {
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
|
||||
this.beanFactory = beanFactory;
|
||||
this.name = name;
|
||||
Class<?> resolvedType = type;
|
||||
if (type == null) {
|
||||
if (resolvedType == null) {
|
||||
resolvedType = beanFactory.getType(name);
|
||||
Assert.notNull(resolvedType, "Unresolvable bean type - explicitly specify the aspect class");
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ public class BeanFactoryAspectJAdvisorsBuilder {
|
||||
* @return the list of {@link org.springframework.aop.Advisor} beans
|
||||
* @see #isEligibleBean
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
public List<Advisor> buildAspectJAdvisors() {
|
||||
List<String> aspectNames = this.aspectBeanNames;
|
||||
|
||||
|
||||
@@ -195,6 +195,7 @@ final class InstantiationModelAwarePointcutAdvisorImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullAway")
|
||||
public boolean isBeforeAdvice() {
|
||||
if (this.isBeforeAdvice == null) {
|
||||
determineAdviceType();
|
||||
@@ -203,6 +204,7 @@ final class InstantiationModelAwarePointcutAdvisorImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullAway")
|
||||
public boolean isAfterAdvice() {
|
||||
if (this.isAfterAdvice == null) {
|
||||
determineAdviceType();
|
||||
|
||||
@@ -98,6 +98,7 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport imple
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
@SuppressWarnings("NullAway")
|
||||
public Object invoke(final MethodInvocation invocation) throws Throwable {
|
||||
Class<?> targetClass = (invocation.getThis() != null ? AopUtils.getTargetClass(invocation.getThis()) : null);
|
||||
final Method userMethod = BridgeMethodResolver.getMostSpecificMethod(invocation.getMethod(), targetClass);
|
||||
|
||||
@@ -54,6 +54,7 @@ class ScopedProxyBeanRegistrationAotProcessor implements BeanRegistrationAotProc
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@SuppressWarnings("NullAway")
|
||||
public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
|
||||
Class<?> beanClass = registeredBean.getBeanClass();
|
||||
if (beanClass.equals(ScopedProxyFactoryBean.class)) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -128,6 +129,7 @@ public abstract class ScopedProxyUtils {
|
||||
* the target bean within a scoped proxy.
|
||||
* @since 4.1.4
|
||||
*/
|
||||
@Contract("null -> false")
|
||||
public static boolean isScopedTarget(@Nullable String beanName) {
|
||||
return (beanName != null && beanName.startsWith(TARGET_NAME_PREFIX));
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.springframework.core.BridgeMethodResolver;
|
||||
import org.springframework.core.CoroutinesUtils;
|
||||
import org.springframework.core.KotlinDetector;
|
||||
import org.springframework.core.MethodIntrospector;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
@@ -73,6 +74,7 @@ public abstract class AopUtils {
|
||||
* @see #isJdkDynamicProxy
|
||||
* @see #isCglibProxy
|
||||
*/
|
||||
@Contract("null -> false")
|
||||
public static boolean isAopProxy(@Nullable Object object) {
|
||||
return (object instanceof SpringProxy && (Proxy.isProxyClass(object.getClass()) ||
|
||||
object.getClass().getName().contains(ClassUtils.CGLIB_CLASS_SEPARATOR)));
|
||||
@@ -86,6 +88,7 @@ public abstract class AopUtils {
|
||||
* @param object the object to check
|
||||
* @see java.lang.reflect.Proxy#isProxyClass
|
||||
*/
|
||||
@Contract("null -> false")
|
||||
public static boolean isJdkDynamicProxy(@Nullable Object object) {
|
||||
return (object instanceof SpringProxy && Proxy.isProxyClass(object.getClass()));
|
||||
}
|
||||
@@ -98,6 +101,7 @@ public abstract class AopUtils {
|
||||
* @param object the object to check
|
||||
* @see ClassUtils#isCglibProxy(Object)
|
||||
*/
|
||||
@Contract("null -> false")
|
||||
public static boolean isCglibProxy(@Nullable Object object) {
|
||||
return (object instanceof SpringProxy &&
|
||||
object.getClass().getName().contains(ClassUtils.CGLIB_CLASS_SEPARATOR));
|
||||
|
||||
@@ -87,6 +87,7 @@ public class AnnotationMatchingPointcut implements Pointcut {
|
||||
* @see AnnotationClassFilter#AnnotationClassFilter(Class, boolean)
|
||||
* @see AnnotationMethodMatcher#AnnotationMethodMatcher(Class, boolean)
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
public AnnotationMatchingPointcut(@Nullable Class<? extends Annotation> classAnnotationType,
|
||||
@Nullable Class<? extends Annotation> methodAnnotationType, boolean checkInherited) {
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ public abstract class AbstractRefreshableTargetSource implements TargetSource, R
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullAway")
|
||||
public synchronized Class<?> getTargetClass() {
|
||||
if (this.targetObject == null) {
|
||||
refresh();
|
||||
|
||||
Reference in New Issue
Block a user