Skip to content

Commit 292a3a4

Browse files
committed
Refine spring-aop arguments nullness
See spring-projectsgh-28797
1 parent 5e9b07b commit 292a3a4

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ public interface ProxyMethodInvocation extends MethodInvocation {
5858
* @return an invocable clone of this invocation.
5959
* {@code proceed()} can be called once per clone.
6060
*/
61-
MethodInvocation invocableClone(Object... arguments);
61+
MethodInvocation invocableClone(@Nullable Object... arguments);
6262

6363
/**
6464
* Set the arguments to be used on subsequent invocations in the any advice
6565
* in this chain.
6666
* @param arguments the argument array
6767
*/
68-
void setArguments(Object... arguments);
68+
void setArguments(@Nullable Object... arguments);
6969

7070
/**
7171
* Add the specified user attribute with the given value to this invocation.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public static boolean equalsAdvisors(AdvisedSupport a, AdvisedSupport b) {
253253
* @return a cloned argument array, or the original if no adaptation is needed
254254
* @since 4.2.3
255255
*/
256-
static Object[] adaptArgumentsIfNecessary(Method method, Object @Nullable [] arguments) {
256+
static @Nullable Object[] adaptArgumentsIfNecessary(Method method, @Nullable Object[] arguments) {
257257
if (ObjectUtils.isEmpty(arguments)) {
258258
return new Object[0];
259259
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
6767

6868
protected final Method method;
6969

70-
protected Object[] arguments;
70+
protected @Nullable Object[] arguments;
7171

7272
private final @Nullable Class<?> targetClass;
7373

@@ -103,7 +103,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
103103
* but would complicate the code. And it would work only for static pointcuts.
104104
*/
105105
protected ReflectiveMethodInvocation(
106-
Object proxy, @Nullable Object target, Method method, Object @Nullable [] arguments,
106+
Object proxy, @Nullable Object target, Method method, @Nullable Object[] arguments,
107107
@Nullable Class<?> targetClass, List<Object> interceptorsAndDynamicMethodMatchers) {
108108

109109
this.proxy = proxy;
@@ -141,12 +141,13 @@ public final Method getMethod() {
141141
}
142142

143143
@Override
144-
public final Object[] getArguments() {
144+
public final @Nullable Object[] getArguments() {
145145
return this.arguments;
146146
}
147147

148148
@Override
149-
public void setArguments(Object... arguments) {
149+
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1113
150+
public void setArguments(@Nullable Object... arguments) {
150151
this.arguments = arguments;
151152
}
152153

@@ -218,7 +219,8 @@ public MethodInvocation invocableClone() {
218219
* @see java.lang.Object#clone()
219220
*/
220221
@Override
221-
public MethodInvocation invocableClone(Object... arguments) {
222+
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1113
223+
public MethodInvocation invocableClone(@Nullable Object... arguments) {
222224
// Force initialization of the user attributes Map,
223225
// for having a shared Map reference in the clone.
224226
if (this.userAttributes == null) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public static List<Advisor> findAdvisorsThatCanApply(List<Advisor> candidateAdvi
347347
* @throws Throwable if thrown by the target method
348348
* @throws org.springframework.aop.AopInvocationException in case of a reflection error
349349
*/
350-
public static @Nullable Object invokeJoinpointUsingReflection(@Nullable Object target, Method method, Object[] args)
350+
public static @Nullable Object invokeJoinpointUsingReflection(@Nullable Object target, Method method, @Nullable Object[] args)
351351
throws Throwable {
352352

353353
// Use reflection to invoke the method.
@@ -377,7 +377,7 @@ public static List<Advisor> findAdvisorsThatCanApply(List<Advisor> candidateAdvi
377377
*/
378378
private static class KotlinDelegate {
379379

380-
public static Object invokeSuspendingFunction(Method method, @Nullable Object target, Object... args) {
380+
public static Object invokeSuspendingFunction(Method method, @Nullable Object target, @Nullable Object... args) {
381381
Continuation<?> continuation = (Continuation<?>) args[args.length -1];
382382
Assert.state(continuation != null, "No Continuation available");
383383
CoroutineContext context = continuation.getContext().minusKey(Job.Key);

0 commit comments

Comments
 (0)