This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 11.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push: new ae2ffdccc4 Fix issue returning null for no args, which would cause a NPE ae2ffdccc4 is described below commit ae2ffdccc485e92adfd137a908715d49c90d62e7 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 ae3095a115..e8936efaf5 100644 --- a/java/org/apache/el/util/ReflectionUtil.java +++ b/java/org/apache/el/util/ReflectionUtil.java @@ -153,12 +153,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