File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed
main/java/org/springframework/expression/spel/ast
test/java/org/springframework/expression/spel Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ protected ValueRef getValueRef(ExpressionState state) throws EvaluationException
68
68
throwIfNotNullSafe (getArgumentTypes (arguments ));
69
69
return ValueRef .NullValueRef .instance ;
70
70
}
71
- return new MethodValueRef (state );
71
+ return new MethodValueRef (state , arguments );
72
72
}
73
73
74
74
@ Override
@@ -246,11 +246,11 @@ private class MethodValueRef implements ValueRef {
246
246
247
247
private final Object [] arguments ;
248
248
249
- public MethodValueRef (ExpressionState state ) {
249
+ public MethodValueRef (ExpressionState state , Object [] arguments ) {
250
250
this .evaluationContext = state .getEvaluationContext ();
251
251
this .value = state .getActiveContextObject ().getValue ();
252
252
this .targetType = state .getActiveContextObject ().getTypeDescriptor ();
253
- this .arguments = getArguments ( state ) ;
253
+ this .arguments = arguments ;
254
254
}
255
255
256
256
@ Override
Original file line number Diff line number Diff line change 29
29
import java .util .List ;
30
30
import java .util .Map ;
31
31
import java .util .Properties ;
32
+ import java .util .concurrent .atomic .AtomicInteger ;
32
33
33
34
import org .junit .Rule ;
34
35
import org .junit .Test ;
@@ -1825,6 +1826,39 @@ public void SPR11348() {
1825
1826
assertEquals ("two" , list .get (1 ));
1826
1827
}
1827
1828
1829
+ @ Test
1830
+ public void SPR11445_simple () {
1831
+ StandardEvaluationContext context = new StandardEvaluationContext (new Spr11445Class ());
1832
+ Expression expr = new SpelExpressionParser ().parseRaw ("echo(parameter())" );
1833
+ assertEquals (1 , expr .getValue (context ));
1834
+ }
1835
+
1836
+ @ Test
1837
+ public void SPR11445_beanReference () {
1838
+ StandardEvaluationContext context = new StandardEvaluationContext ();
1839
+ context .setBeanResolver (new Spr11445Class ());
1840
+ Expression expr = new SpelExpressionParser ().parseRaw ("@bean.echo(@bean.parameter())" );
1841
+ assertEquals (1 , expr .getValue (context ));
1842
+ }
1843
+
1844
+ static class Spr11445Class implements BeanResolver {
1845
+
1846
+ private final AtomicInteger counter = new AtomicInteger ();
1847
+
1848
+ public int echo (int invocation ) {
1849
+ return invocation ;
1850
+ }
1851
+
1852
+ public int parameter () {
1853
+ return counter .incrementAndGet ();
1854
+ }
1855
+
1856
+ @ Override
1857
+ public Object resolve (EvaluationContext context , String beanName ) throws AccessException {
1858
+ return beanName .equals ("bean" ) ? this : null ;
1859
+ }
1860
+ }
1861
+
1828
1862
@ Test
1829
1863
public void SPR11494 () {
1830
1864
Expression exp = new SpelExpressionParser ().parseExpression ("T(java.util.Arrays).asList('a','b')" );
You can’t perform that action at this time.
0 commit comments