Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50790
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 17 Feb 2011 09:59:30 +0000 (09:59 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 17 Feb 2011 09:59:30 +0000 (09:59 +0000)
Improve method resolution in EL expressions
Add test cases for this bug

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1071561 13f79535-47bb-0310-9956-ffa450edef68

java/javax/el/BeanELResolver.java
java/org/apache/el/parser/AstValue.java
test/org/apache/el/TestMethodExpressionImpl.java
webapps/docs/changelog.xml

index 4f286cb..7ba9ce0 100644 (file)
@@ -413,7 +413,8 @@ public class BeanELResolver extends ELResolver {
             }
             Method[] methods = clazz.getMethods();
             for (Method m : methods) {
-                if (m.getParameterTypes().length == paramCount) {
+                if (methodName.equals(m.getName()) && 
+                        m.getParameterTypes().length == paramCount) {
                     // Same number of parameters - use the first match
                     matchingMethod = m;
                     break;
index 02ad92f..92dab46 100644 (file)
@@ -156,8 +156,8 @@ public final class AstValue extends SimpleNode {
                 AstMethodParameters mps =
                     (AstMethodParameters) this.children[i+1];
                 // This is a method
-                base = resolver.invoke(ctx, base, suffix,
-                        mps.getParameterTypes(ctx), mps.getParameters(ctx));
+                base = resolver.invoke(ctx, base, suffix, null,
+                        mps.getParameters(ctx));
                 i+=2;
             } else {
                 // This is a property
index fd7cb96..772e01c 100644 (file)
@@ -349,4 +349,18 @@ public class TestMethodExpressionImpl extends TestCase {
         String actual = (String) me1.invoke(context, null);
         assertEquals("Hello Tomcat from B", actual);
     }
+    
+    public void testBug50790a() throws Exception {
+        ValueExpression ve = factory.createValueExpression(context,
+                "#{beanAA.name.contains(beanA.name)}", java.lang.Boolean.class);
+        Boolean actual = (Boolean) ve.getValue(context);
+        assertEquals(Boolean.TRUE, actual);
+    }
+
+    public void testBug50790b() throws Exception {
+        ValueExpression ve = factory.createValueExpression(context,
+                "#{beanA.name.contains(beanAA.name)}", java.lang.Boolean.class);
+        Boolean actual = (Boolean) ve.getValue(context);
+        assertEquals(Boolean.FALSE, actual);
+    }
 }
index 75f1dec..8b06f4e 100644 (file)
         not result in String constants that are too long for valid Java code.
         (markt)
       </fix>
+      <fix>
+        <bug>50790</bug>: Improve method resolution in EL expressions. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Cluster">