Skip to content

Commit ff738e7

Browse files
committed
Polish contribution
Closes gh-1070
1 parent f075aac commit ff738e7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* </ol>
3535
*
3636
* @author Stephane Nicoll
37+
* @author Sergey Podgurskiy
3738
* @since 4.2
3839
*/
3940
public class MethodBasedEvaluationContext extends StandardEvaluationContext {
@@ -89,7 +90,7 @@ protected void lazyLoadArguments() {
8990
String[] parameterNames = this.paramDiscoverer.getParameterNames(this.method);
9091
// save parameter names (if discovered)
9192
if (parameterNames != null) {
92-
for (int i = 0; i < args.length; i++) {
93+
for (int i = 0; i < this.args.length; i++) {
9394
setVariable(parameterNames[i], this.args[i]);
9495
}
9596
}

spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -30,6 +30,7 @@
3030
* Unit tests for {@link MethodBasedEvaluationContext}.
3131
*
3232
* @author Stephane Nicoll
33+
* @author Sergey Podgurskiy
3334
*/
3435
public class MethodBasedEvaluationContextTests {
3536

@@ -92,10 +93,11 @@ public void varArgSingle() {
9293
@Test
9394
public void varArgMultiple() {
9495
Method method = ReflectionUtils.findMethod(SampleMethods.class, "hello", Boolean.class, String[].class);
95-
MethodBasedEvaluationContext context = createEvaluationContext(method, new Object[] {null, new String[]{"hello", "hi"}});
96+
MethodBasedEvaluationContext context = createEvaluationContext(method,
97+
new Object[] {null, new String[]{"hello", "hi"}});
9698

9799
assertNull(context.lookupVariable("p0"));
98-
assertNotNull(context.lookupVariable("p1"));
100+
assertArrayEquals(new String[]{"hello", "hi"}, (String[]) context.lookupVariable("p1"));
99101
}
100102

101103
private MethodBasedEvaluationContext createEvaluationContext(Method method, Object[] args) {
@@ -109,9 +111,10 @@ private static class SampleMethods {
109111
private void hello(String foo, Boolean flag) {
110112
}
111113

112-
private void hello(Boolean flag, String ... vararg){
114+
private void hello(Boolean flag, String... vararg){
113115

114116
}
117+
115118
}
116119

117120
}

0 commit comments

Comments
 (0)