12
12
import org .springframework .expression .ExpressionParser ;
13
13
import org .springframework .expression .spel .standard .SpelExpressionParser ;
14
14
import org .springframework .expression .spel .support .StandardEvaluationContext ;
15
+ import org .springframework .util .ObjectUtils ;
15
16
import org .springframework .util .StringUtils ;
16
17
17
18
import java .lang .reflect .Method ;
@@ -56,10 +57,10 @@ private Method getMethod(JoinPoint joinPoint) {
56
57
private List <String > getSpelDefinitionKey (String [] definitionKeys , Method method , Object [] parameterValues ) {
57
58
List <String > definitionKeyList = new ArrayList <>();
58
59
for (String definitionKey : definitionKeys ) {
59
- if (definitionKey != null && ! definitionKey .isEmpty ()) {
60
+ if (! ObjectUtils .isEmpty (definitionKey )) {
60
61
EvaluationContext context = new MethodBasedEvaluationContext (null , method , parameterValues , nameDiscoverer );
61
- String key = parser .parseExpression (definitionKey ).getValue (context ). toString ( );
62
- definitionKeyList .add (key );
62
+ Object objKey = parser .parseExpression (definitionKey ).getValue (context );
63
+ definitionKeyList .add (ObjectUtils . nullSafeToString ( objKey ) );
63
64
}
64
65
}
65
66
return definitionKeyList ;
@@ -71,11 +72,12 @@ private List<String> getParameterKey(Parameter[] parameters, Object[] parameterV
71
72
if (parameters [i ].getAnnotation (KlockKey .class ) != null ) {
72
73
KlockKey keyAnnotation = parameters [i ].getAnnotation (KlockKey .class );
73
74
if (keyAnnotation .value ().isEmpty ()) {
74
- parameterKey .add (parameterValues [i ].toString ());
75
+ Object parameterValue = parameterValues [i ];
76
+ parameterKey .add (ObjectUtils .nullSafeToString (parameterValue ));
75
77
} else {
76
78
StandardEvaluationContext context = new StandardEvaluationContext (parameterValues [i ]);
77
- String key = parser .parseExpression (keyAnnotation .value ()).getValue (context ). toString ( );
78
- parameterKey .add (key );
79
+ Object key = parser .parseExpression (keyAnnotation .value ()).getValue (context );
80
+ parameterKey .add (ObjectUtils . nullSafeToString ( key ) );
79
81
}
80
82
}
81
83
}
0 commit comments