Author: remy.maucherat(a)jboss.com
Date: 2012-01-16 06:27:00 -0500 (Mon, 16 Jan 2012)
New Revision: 1924
Modified:
trunk/java/org/apache/el/parser/AstValue.java
trunk/test/java/org/apache/el/TestMethodExpressionImpl.java
trunk/webapps/docs/changelog.xml
Log:
Port another EL fix.
Modified: trunk/java/org/apache/el/parser/AstValue.java
===================================================================
--- trunk/java/org/apache/el/parser/AstValue.java 2012-01-13 16:48:38 UTC (rev 1923)
+++ trunk/java/org/apache/el/parser/AstValue.java 2012-01-16 11:27:00 UTC (rev 1924)
@@ -245,8 +245,8 @@
Method m = null;
Object[] values = null;
if (isParametersProvided()) {
- values = ((AstMethodParameters)
- this.jjtGetChild(2)).getParameters(ctx);
+ values = ((AstMethodParameters) this.jjtGetChild(
+ this.jjtGetNumChildren() - 1)).getParameters(ctx);
Class<?>[] types = getTypesFromValues(values);
m = ReflectionUtil.getMethod(t.base, t.property, types);
} else {
@@ -329,9 +329,13 @@
*/
@Override
public boolean isParametersProvided() {
- if (this.children.length > 2
- && this.jjtGetChild(2) instanceof AstMethodParameters) {
- return true;
+ // Assumption is that method parameters, if present, will be the last
+ // child
+ int len = children.length;
+ if (len > 2) {
+ if (this.jjtGetChild(len - 1) instanceof AstMethodParameters) {
+ return true;
+ }
}
return false;
}
Modified: trunk/test/java/org/apache/el/TestMethodExpressionImpl.java
===================================================================
--- trunk/test/java/org/apache/el/TestMethodExpressionImpl.java 2012-01-13 16:48:38 UTC
(rev 1923)
+++ trunk/test/java/org/apache/el/TestMethodExpressionImpl.java 2012-01-16 11:27:00 UTC
(rev 1924)
@@ -444,4 +444,17 @@
Boolean actual = (Boolean) ve.getValue(context);
assertEquals(Boolean.FALSE, actual);
}
+
+ @Test
+ public void testBug52445a() {
+ MethodExpression me = factory.createMethodExpression(context,
+ "${beanA.setBean(beanBB)}", null ,
+ new Class<?>[] { TesterBeanB.class });
+ me.invoke(context, null);
+
+ MethodExpression me1 = factory.createMethodExpression(context,
+ "${beanA.bean.sayHello()}", null, null);
+ String actual = (String) me1.invoke(context, null);
+ assertEquals("Hello from BB", actual);
+ }
}
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2012-01-13 16:48:38 UTC (rev 1923)
+++ trunk/webapps/docs/changelog.xml 2012-01-16 11:27:00 UTC (rev 1924)
@@ -30,6 +30,9 @@
<fix>
Resolve EL variables when returning value references. (markt)
</fix>
+ <fix>
+ <bug>52445</bug>: Do not assume EL method expressions have exactly
three elements. (markt)
+ </fix>
</changelog>
</subsection>
</section>
Show replies by date