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 515c5dc6b6..6c56453504 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 @@ -34,6 +34,7 @@ import org.springframework.util.ObjectUtils; * * * @author Stephane Nicoll + * @author Sergey Podgurskiy * @since 4.2 */ public class MethodBasedEvaluationContext extends StandardEvaluationContext { @@ -89,7 +90,7 @@ public class MethodBasedEvaluationContext extends StandardEvaluationContext { String[] parameterNames = this.paramDiscoverer.getParameterNames(this.method); // save parameter names (if discovered) if (parameterNames != null) { - for (int i = 0; i < args.length; i++) { + for (int i = 0; i < this.args.length; i++) { setVariable(parameterNames[i], this.args[i]); } } diff --git a/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java b/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java index 12bf964016..2711b006ba 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -30,6 +30,7 @@ import static org.junit.Assert.*; * Unit tests for {@link MethodBasedEvaluationContext}. * * @author Stephane Nicoll + * @author Sergey Podgurskiy */ public class MethodBasedEvaluationContextTests { @@ -92,10 +93,11 @@ public class MethodBasedEvaluationContextTests { @Test public void varArgMultiple() { Method method = ReflectionUtils.findMethod(SampleMethods.class, "hello", Boolean.class, String[].class); - MethodBasedEvaluationContext context = createEvaluationContext(method, new Object[] {null, new String[]{"hello", "hi"}}); + MethodBasedEvaluationContext context = createEvaluationContext(method, + new Object[] {null, new String[]{"hello", "hi"}}); assertNull(context.lookupVariable("p0")); - assertNotNull(context.lookupVariable("p1")); + assertArrayEquals(new String[]{"hello", "hi"}, (String[]) context.lookupVariable("p1")); } private MethodBasedEvaluationContext createEvaluationContext(Method method, Object[] args) { @@ -109,9 +111,10 @@ public class MethodBasedEvaluationContextTests { private void hello(String foo, Boolean flag) { } - private void hello(Boolean flag, String ... vararg){ + private void hello(Boolean flag, String... vararg){ } + } } \ No newline at end of file