Author: markt
Date: Thu Feb 17 09:59:30 2011
New Revision: 1071561

URL: http://svn.apache.org/viewvc?rev=1071561&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50790
Improve method resolution in EL expressions
Add test cases for this bug

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

Modified: tomcat/trunk/java/javax/el/BeanELResolver.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/BeanELResolver.java?rev=1071561&r1=1071560&r2=1071561&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/BeanELResolver.java (original)
+++ tomcat/trunk/java/javax/el/BeanELResolver.java Thu Feb 17 09:59:30 2011
@@ -413,7 +413,8 @@ public class BeanELResolver extends ELRe
             }
             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;

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=1071561&r1=1071560&r2=1071561&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstValue.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstValue.java Thu Feb 17 09:59:30 
2011
@@ -156,8 +156,8 @@ public final class AstValue extends Simp
                 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

Modified: tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java?rev=1071561&r1=1071560&r2=1071561&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java (original)
+++ tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java Thu Feb 17 
09:59:30 2011
@@ -349,4 +349,18 @@ public class TestMethodExpressionImpl ex
         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);
+    }
 }

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1071561&r1=1071560&r2=1071561&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Feb 17 09:59:30 2011
@@ -107,6 +107,9 @@
         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">



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to