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 c63aa4de09 Fix some error reporting
c63aa4de09 is described below

commit c63aa4de099a8a42b801c26c7c9787009ba975f7
Author: remm <r...@apache.org>
AuthorDate: Wed Sep 20 15:43:55 2023 +0200

    Fix some error reporting
    
    When a method is matched but access is not possible, null could be
    returned instead of the normal exception.
    Found by coverity.
---
 java/org/apache/el/util/ReflectionUtil.java | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/el/util/ReflectionUtil.java 
b/java/org/apache/el/util/ReflectionUtil.java
index 02eeccd27d..015133bc9d 100644
--- a/java/org/apache/el/util/ReflectionUtil.java
+++ b/java/org/apache/el/util/ReflectionUtil.java
@@ -252,7 +252,13 @@ public class ReflectionUtil {
             // If a method is found where every parameter matches exactly,
             // and no vars args are present, return it
             if (exactMatch == paramCount && varArgsMatch == 0) {
-                return getMethod(base.getClass(), base, m);
+                Method result = getMethod(base.getClass(), base, m);
+                if (result == null) {
+                    throw new MethodNotFoundException(MessageFactory.get(
+                            "error.method.notfound", base, property,
+                            paramString(paramTypes)));
+                }
+                return result;
             }
 
             candidates.put(m, new MatchResult(
@@ -299,7 +305,13 @@ public class ReflectionUtil {
                         paramString(paramTypes)));
         }
 
-        return getMethod(base.getClass(), base, match);
+        Method result = getMethod(base.getClass(), base, match);
+        if (result == null) {
+            throw new MethodNotFoundException(MessageFactory.get(
+                    "error.method.notfound", base, property,
+                    paramString(paramTypes)));
+        }
+        return result;
     }
 
     /*


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

Reply via email to