diff --git a/spring-context/src/main/java/org/springframework/context/expression/MethodBasedEvaluationContext.java b/spring-context/src/main/java/org/springframework/context/expression/MethodBasedEvaluationContext.java index a20446fd9c..827a4df05b 100644 --- a/spring-context/src/main/java/org/springframework/context/expression/MethodBasedEvaluationContext.java +++ b/spring-context/src/main/java/org/springframework/context/expression/MethodBasedEvaluationContext.java @@ -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 { } setVariable("a" + i, value); setVariable("p" + i, value); - if (paramNames != null) { + if (paramNames != null && paramNames[i] != null) { setVariable(paramNames[i], value); } } diff --git a/spring-core/src/main/java/org/springframework/core/ParameterNameDiscoverer.java b/spring-core/src/main/java/org/springframework/core/ParameterNameDiscoverer.java index 8c551f2140..ba63de5b3d 100644 --- a/spring-core/src/main/java/org/springframework/core/ParameterNameDiscoverer.java +++ b/spring-core/src/main/java/org/springframework/core/ParameterNameDiscoverer.java @@ -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; 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. + *
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 { 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. + *
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 */