Skip to content

Commit

Permalink
Refine spring-aop arguments nullness
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeleuze committed Jan 6, 2025
1 parent 5e9b07b commit 292a3a4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public static boolean equalsAdvisors(AdvisedSupport a, AdvisedSupport b) {
* @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];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -141,12 +141,13 @@ public final Method getMethod() {
}

@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;
}

Expand Down Expand Up @@ -218,7 +219,8 @@ public MethodInvocation invocableClone() {
* @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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public static List<Advisor> findAdvisorsThatCanApply(List<Advisor> candidateAdvi
* @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.
Expand Down Expand Up @@ -377,7 +377,7 @@ public static List<Advisor> findAdvisorsThatCanApply(List<Advisor> candidateAdvi
*/
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);
Expand Down

0 comments on commit 292a3a4

Please sign in to comment.