Browse Source

Refine spring-aop arguments nullness

See gh-28797
pull/34207/head
Sébastien Deleuze 12 months ago
parent
commit
292a3a4895
  1. 4
      spring-aop/src/main/java/org/springframework/aop/ProxyMethodInvocation.java
  2. 2
      spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java
  3. 12
      spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java
  4. 4
      spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java

4
spring-aop/src/main/java/org/springframework/aop/ProxyMethodInvocation.java

@ -58,14 +58,14 @@ public interface ProxyMethodInvocation extends MethodInvocation { @@ -58,14 +58,14 @@ public interface ProxyMethodInvocation extends MethodInvocation {
* @return an invocable clone of this invocation.
* {@code proceed()} can be called once per clone.
*/
MethodInvocation invocableClone(Object... arguments);
MethodInvocation invocableClone(@Nullable Object... arguments);
/**
* Set the arguments to be used on subsequent invocations in the any advice
* in this chain.
* @param arguments the argument array
*/
void setArguments(Object... arguments);
void setArguments(@Nullable Object... arguments);
/**
* Add the specified user attribute with the given value to this invocation.

2
spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java

@ -253,7 +253,7 @@ public abstract class AopProxyUtils { @@ -253,7 +253,7 @@ public abstract class AopProxyUtils {
* @return a cloned argument array, or the original if no adaptation is needed
* @since 4.2.3
*/
static Object[] adaptArgumentsIfNecessary(Method method, Object @Nullable [] arguments) {
static @Nullable Object[] adaptArgumentsIfNecessary(Method method, @Nullable Object[] arguments) {
if (ObjectUtils.isEmpty(arguments)) {
return new Object[0];
}

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

@ -67,7 +67,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea @@ -67,7 +67,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
protected final Method method;
protected Object[] arguments;
protected @Nullable Object[] arguments;
private final @Nullable Class<?> targetClass;
@ -103,7 +103,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea @@ -103,7 +103,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
* but would complicate the code. And it would work only for static pointcuts.
*/
protected ReflectiveMethodInvocation(
Object proxy, @Nullable Object target, Method method, Object @Nullable [] arguments,
Object proxy, @Nullable Object target, Method method, @Nullable Object[] arguments,
@Nullable Class<?> targetClass, List<Object> interceptorsAndDynamicMethodMatchers) {
this.proxy = proxy;
@ -141,12 +141,13 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea @@ -141,12 +141,13 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
}
@Override
public final Object[] getArguments() {
public final @Nullable Object[] getArguments() {
return this.arguments;
}
@Override
public void setArguments(Object... arguments) {
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1113
public void setArguments(@Nullable Object... arguments) {
this.arguments = arguments;
}
@ -218,7 +219,8 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea @@ -218,7 +219,8 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
* @see java.lang.Object#clone()
*/
@Override
public MethodInvocation invocableClone(Object... arguments) {
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1113
public MethodInvocation invocableClone(@Nullable Object... arguments) {
// Force initialization of the user attributes Map,
// for having a shared Map reference in the clone.
if (this.userAttributes == null) {

4
spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java

@ -347,7 +347,7 @@ public abstract class AopUtils { @@ -347,7 +347,7 @@ public abstract class AopUtils {
* @throws Throwable if thrown by the target method
* @throws org.springframework.aop.AopInvocationException in case of a reflection error
*/
public static @Nullable Object invokeJoinpointUsingReflection(@Nullable Object target, Method method, Object[] args)
public static @Nullable Object invokeJoinpointUsingReflection(@Nullable Object target, Method method, @Nullable Object[] args)
throws Throwable {
// Use reflection to invoke the method.
@ -377,7 +377,7 @@ public abstract class AopUtils { @@ -377,7 +377,7 @@ public abstract class AopUtils {
*/
private static class KotlinDelegate {
public static Object invokeSuspendingFunction(Method method, @Nullable Object target, Object... args) {
public static Object invokeSuspendingFunction(Method method, @Nullable Object target, @Nullable Object... args) {
Continuation<?> continuation = (Continuation<?>) args[args.length -1];
Assert.state(continuation != null, "No Continuation available");
CoroutineContext context = continuation.getContext().minusKey(Job.Key);

Loading…
Cancel
Save