This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 8ce5ca065c Review "Accept zero varargs elements in EL method 
expression calls"
8ce5ca065c is described below

commit 8ce5ca065c440cfee769b4266e0a3e008ee0b1c8
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Nov 5 15:58:25 2026 +0000

    Review "Accept zero varargs elements in EL method expression calls"
    
    Expand test coverage
    
    Co-authored by: Claude / Sonnet 5.5
---
 test/org/apache/el/TestMethodExpressionImpl.java | 45 ++++++++++++++++++++----
 1 file changed, 39 insertions(+), 6 deletions(-)

diff --git a/test/org/apache/el/TestMethodExpressionImpl.java 
b/test/org/apache/el/TestMethodExpressionImpl.java
index dbd35b0b90..656aac6fae 100644
--- a/test/org/apache/el/TestMethodExpressionImpl.java
+++ b/test/org/apache/el/TestMethodExpressionImpl.java
@@ -21,6 +21,7 @@ import java.util.Set;
 import java.util.function.Function;
 
 import jakarta.el.ELContext;
+import jakarta.el.ELException;
 import jakarta.el.ELManager;
 import jakarta.el.ELProcessor;
 import jakarta.el.ExpressionFactory;
@@ -494,15 +495,47 @@ public class TestMethodExpressionImpl {
     }
 
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testBug60844() {
-        // Fewer parameter values than the minimum required by a varargs
-        // method (here, the fixed parameters only). A single value would be
-        // a valid number of arguments for this method, so the call below
-        // with no values is the too-few-parameters case.
+        // Fewer parameter values than the minimum required by a varargs 
method. The minimum is the number of fixed
+        // parameters (one here), not the total number of parameters, and that 
is the minimum that must be reported.
         MethodExpression me2 = factory.createMethodExpression(context, 
"${beanC.sayHello}", null,
                 new Class[] { TesterBeanA.class });
-        me2.invoke(context, new Object[] { });
+        try {
+            me2.invoke(context, new Object[] {});
+            Assert.fail("No exception");
+        } catch (IllegalArgumentException iae) {
+            String msg = iae.getMessage();
+            Assert.assertTrue(msg, msg.contains("[sayHello]"));
+            // Called with [0] parameter(s), expected at least [1]
+            Assert.assertTrue(msg, msg.contains("[0]"));
+            Assert.assertTrue(msg, msg.contains("[1]"));
+            Assert.assertFalse(msg, msg.contains("[2]"));
+        }
+    }
+
+
+    @Test
+    public void testBug60844NullParameters() {
+        MethodExpression me2 = factory.createMethodExpression(context, 
"${beanC.sayHello}", null,
+                new Class[] { TesterBeanA.class, TesterBeanB.class });
+        try {
+            me2.invoke(context, null);
+            Assert.fail("No exception");
+        } catch (IllegalArgumentException iae) {
+            String msg = iae.getMessage();
+            Assert.assertTrue(msg, msg.contains("[sayHello]"));
+        }
+    }
+
+
+    @Test(expected = ELException.class)
+    public void testBug60844WrongType() {
+        // The original bug 60844 call: a single value of the wrong type. A 
single value is a valid number of
+        // arguments for the varargs method so the failure is now reported 
when the argument is coerced.
+        MethodExpression me2 = factory.createMethodExpression(context, 
"${beanC.sayHello}", null,
+                new Class[] { TesterBeanA.class, TesterBeanB.class });
+        me2.invoke(context, new Object[] { new Object() });
     }
 
 


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

Reply via email to