1
1
/*
2
- * Copyright 2002-2023 the original author or authors.
2
+ * Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
43
43
import org .springframework .aop .support .StaticMethodMatcher ;
44
44
import org .springframework .core .DefaultParameterNameDiscoverer ;
45
45
import org .springframework .core .ParameterNameDiscoverer ;
46
+ import org .springframework .lang .Contract ;
46
47
import org .springframework .util .Assert ;
47
48
import org .springframework .util .ClassUtils ;
48
49
import org .springframework .util .CollectionUtils ;
@@ -258,10 +259,11 @@ public void setArgumentNames(String argumentNames) {
258
259
* or in an advice annotation.
259
260
* @param argumentNames list of argument names
260
261
*/
261
- public void setArgumentNamesFromStringArray (String ... argumentNames ) {
262
+ public void setArgumentNamesFromStringArray (@ Nullable String ... argumentNames ) {
262
263
this .argumentNames = new String [argumentNames .length ];
263
264
for (int i = 0 ; i < argumentNames .length ; i ++) {
264
- this .argumentNames [i ] = argumentNames [i ].strip ();
265
+ String argumentName = argumentNames [i ];
266
+ this .argumentNames [i ] = argumentName != null ? argumentName .strip () : null ;
265
267
if (!isVariableName (this .argumentNames [i ])) {
266
268
throw new IllegalArgumentException (
267
269
"'argumentNames' property of AbstractAspectJAdvice contains an argument name '" +
@@ -274,7 +276,7 @@ public void setArgumentNamesFromStringArray(String... argumentNames) {
274
276
if (firstArgType == JoinPoint .class ||
275
277
firstArgType == ProceedingJoinPoint .class ||
276
278
firstArgType == JoinPoint .StaticPart .class ) {
277
- String [] oldNames = this .argumentNames ;
279
+ @ Nullable String [] oldNames = this .argumentNames ;
278
280
this .argumentNames = new String [oldNames .length + 1 ];
279
281
this .argumentNames [0 ] = "THIS_JOIN_POINT" ;
280
282
System .arraycopy (oldNames , 0 , this .argumentNames , 1 , oldNames .length );
@@ -346,7 +348,8 @@ protected Class<?> getDiscoveredThrowingType() {
346
348
return this .discoveredThrowingType ;
347
349
}
348
350
349
- private static boolean isVariableName (String name ) {
351
+ @ Contract ("null -> false" )
352
+ private static boolean isVariableName (@ Nullable String name ) {
350
353
return AspectJProxyUtils .isVariableName (name );
351
354
}
352
355
@@ -456,6 +459,7 @@ protected ParameterNameDiscoverer createParameterNameDiscoverer() {
456
459
return discoverer ;
457
460
}
458
461
462
+ @ SuppressWarnings ("NullAway" ) // Dataflow analysis limitation
459
463
private void bindExplicitArguments (int numArgumentsLeftToBind ) {
460
464
Assert .state (this .argumentNames != null , "No argument names available" );
461
465
this .argumentBindings = new HashMap <>();
@@ -623,8 +627,8 @@ protected Object invokeAdviceMethod(JoinPoint jp, @Nullable JoinPointMatch jpMat
623
627
return invokeAdviceMethodWithGivenArgs (argBinding (jp , jpMatch , returnValue , t ));
624
628
}
625
629
626
- protected Object invokeAdviceMethodWithGivenArgs (Object [] args ) throws Throwable {
627
- Object [] actualArgs = args ;
630
+ protected Object invokeAdviceMethodWithGivenArgs (@ Nullable Object [] args ) throws Throwable {
631
+ @ Nullable Object [] actualArgs = args ;
628
632
if (this .aspectJAdviceMethod .getParameterCount () == 0 ) {
629
633
actualArgs = null ;
630
634
}
0 commit comments