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

remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 068e779df9 Fix issue returning null for no args, which would cause a 
NPE
068e779df9 is described below

commit 068e779df92a4fe7fff775212daf51dd2b848c20
Author: remm <r...@apache.org>
AuthorDate: Mon Jul 7 14:01:20 2025 +0200

    Fix issue returning null for no args, which would cause a NPE
    
    Although the comment says that this duplicates jakarta.el.Util, this
    does not seem to be exactly the case.
    All paths should throw MethodNotFoundException instead of returning
    null. In jakarta.el.Util all callers are expecting null instead, so it
    works fine.
    Found by Coverity.
---
 java/org/apache/el/util/ReflectionUtil.java | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/el/util/ReflectionUtil.java 
b/java/org/apache/el/util/ReflectionUtil.java
index 6f662f30e8..82866fce98 100644
--- a/java/org/apache/el/util/ReflectionUtil.java
+++ b/java/org/apache/el/util/ReflectionUtil.java
@@ -155,12 +155,20 @@ public class ReflectionUtil {
 
         // Fast path: when no arguments exist, there can only be one matching 
method and no need for coercion.
         if (paramCount == 0) {
+            Method result = null;
+            Throwable t = null;
             try {
                 Method method = clazz.getMethod(methodName, paramTypes);
-                return getMethod(clazz, base, method);
+                result = getMethod(clazz, base, method);
             } catch (NoSuchMethodException | SecurityException e) {
-                // Fall through to broader, slower logic
+                // Fall through
+                t = e;
             }
+            if (result == null) {
+                throw new MethodNotFoundException(
+                        MessageFactory.get("error.method.notfound", base, 
property, paramString(paramTypes)), t);
+            }
+            return result;
         }
 
         Method[] methods = clazz.getMethods();


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to