Skip to content

Commit 1b26f2f

Browse files
committed
ParameterNameDiscoverer may return individual null entries in an array
Issue: SPR-17565 (cherry picked from commit c48672c)
1 parent 6ca2cb5 commit 1b26f2f

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

spring-context/src/main/java/org/springframework/context/expression/MethodBasedEvaluationContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -101,7 +101,7 @@ else if (argsCount > i) {
101101
}
102102
setVariable("a" + i, value);
103103
setVariable("p" + i, value);
104-
if (paramNames != null) {
104+
if (paramNames != null && paramNames[i] != null) {
105105
setVariable(paramNames[i], value);
106106
}
107107
}

spring-core/src/main/java/org/springframework/core/ParameterNameDiscoverer.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,19 +36,23 @@
3636
public interface ParameterNameDiscoverer {
3737

3838
/**
39-
* Return parameter names for this method,
40-
* or {@code null} if they cannot be determined.
41-
* @param method method to find parameter names for
39+
* Return parameter names for a method, or {@code null} if they cannot be determined.
40+
* <p>Individual entries in the array may be {@code null} if parameter names are only
41+
* available for some parameters of the given method but not for others. However,
42+
* it is recommended to use stub parameter names instead wherever feasible.
43+
* @param method the method to find parameter names for
4244
* @return an array of parameter names if the names can be resolved,
4345
* or {@code null} if they cannot
4446
*/
4547
@Nullable
4648
String[] getParameterNames(Method method);
4749

4850
/**
49-
* Return parameter names for this constructor,
50-
* or {@code null} if they cannot be determined.
51-
* @param ctor constructor to find parameter names for
51+
* Return parameter names for a constructor, or {@code null} if they cannot be determined.
52+
* <p>Individual entries in the array may be {@code null} if parameter names are only
53+
* available for some parameters of the given constructor but not for others. However,
54+
* it is recommended to use stub parameter names instead wherever feasible.
55+
* @param ctor the constructor to find parameter names for
5256
* @return an array of parameter names if the names can be resolved,
5357
* or {@code null} if they cannot
5458
*/

0 commit comments

Comments
 (0)