Browse Source

ParameterNameDiscoverer may return individual null entries in an array

Issue: SPR-17565

(cherry picked from commit c48672c4c7)
pull/23430/head
Juergen Hoeller 6 years ago
parent
commit
1b26f2fb31
  1. 4
      spring-context/src/main/java/org/springframework/context/expression/MethodBasedEvaluationContext.java
  2. 18
      spring-core/src/main/java/org/springframework/core/ParameterNameDiscoverer.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -101,7 +101,7 @@ public class MethodBasedEvaluationContext extends StandardEvaluationContext { @@ -101,7 +101,7 @@ public class MethodBasedEvaluationContext extends StandardEvaluationContext {
}
setVariable("a" + i, value);
setVariable("p" + i, value);
if (paramNames != null) {
if (paramNames != null && paramNames[i] != null) {
setVariable(paramNames[i], value);
}
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -36,9 +36,11 @@ import org.springframework.lang.Nullable; @@ -36,9 +36,11 @@ import org.springframework.lang.Nullable;
public interface ParameterNameDiscoverer {
/**
* Return parameter names for this method,
* or {@code null} if they cannot be determined.
* @param method method to find parameter names for
* Return parameter names for a method, or {@code null} if they cannot be determined.
* <p>Individual entries in the array may be {@code null} if parameter names are only
* available for some parameters of the given method but not for others. However,
* it is recommended to use stub parameter names instead wherever feasible.
* @param method the method to find parameter names for
* @return an array of parameter names if the names can be resolved,
* or {@code null} if they cannot
*/
@ -46,9 +48,11 @@ public interface ParameterNameDiscoverer { @@ -46,9 +48,11 @@ public interface ParameterNameDiscoverer {
String[] getParameterNames(Method method);
/**
* Return parameter names for this constructor,
* or {@code null} if they cannot be determined.
* @param ctor constructor to find parameter names for
* Return parameter names for a constructor, or {@code null} if they cannot be determined.
* <p>Individual entries in the array may be {@code null} if parameter names are only
* available for some parameters of the given constructor but not for others. However,
* it is recommended to use stub parameter names instead wherever feasible.
* @param ctor the constructor to find parameter names for
* @return an array of parameter names if the names can be resolved,
* or {@code null} if they cannot
*/

Loading…
Cancel
Save