Author: markt
Date: Fri Jan 13 20:29:13 2012
New Revision: 1231285
URL: http://svn.apache.org/viewvc?rev=1231285&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=52445
Do not assume method expressions have exactly three elements
Includes a test case
Modified:
tomcat/trunk/java/org/apache/el/parser/AstValue.java
tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java
Modified: tomcat/trunk/java/org/apache/el/parser/AstValue.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstValue.java?rev=1231285&r1=1231284&r2=1231285&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstValue.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstValue.java Fri Jan 13 20:29:13
2012
@@ -245,8 +245,8 @@ public final class AstValue extends Simp
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 @@ public final class AstValue extends Simp
*/
@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: tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java?rev=1231285&r1=1231284&r2=1231285&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java (original)
+++ tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java Fri Jan 13
20:29:13 2012
@@ -399,4 +399,18 @@ public class TestMethodExpressionImpl {
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);
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]