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

rmaucher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 6d541540656b989d518c80acccfa38e348918ea9
Author: opencode <[email protected]>
AuthorDate: Sun Oct 11 21:13:21 2026 +0200

    Report a class name filter match failure via the documented exception when 
no Log is configured
    
    CustomObjectInputStream's constructor permits a null Log whenever
    warnOnFailure is false, and the javadoc documents that nullability
    rule. However, checkAllowed() fell through to an unconditional
    log.isDebugEnabled() call when a class name was rejected without
    warning, so a null Log caused a NullPointerException to propagate
    out of resolveClass()/resolveProxyClass() instead of the documented
    InvalidClassException. Both production call sites (StandardManager,
    StoreBase) always pass a non-null logger, so the defect was latent
    within Tomcat, but it violated the documented contract for any
    external or embedded caller that configured a filter with a null
    logger.
    
    Guard the debug-level branch with a null check. The warn branch
    needs no guard: doLog implies warnOnFailure which, together with the
    constructor guard, implies a non-null Log. Tightening the
    constructor to reject null Log values was deliberately not done,
    since the javadoc contract intentionally allows the null logger in
    non-warn mode.
---
 java/org/apache/catalina/util/CustomObjectInputStream.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/util/CustomObjectInputStream.java 
b/java/org/apache/catalina/util/CustomObjectInputStream.java
index 8b0ec3a49f..fdb270724c 100644
--- a/java/org/apache/catalina/util/CustomObjectInputStream.java
+++ b/java/org/apache/catalina/util/CustomObjectInputStream.java
@@ -184,7 +184,8 @@ public final class CustomObjectInputStream extends 
ObjectInputStream {
             String msg = sm.getString("customObjectInputStream.nomatch", name, 
allowedClassNameFilter);
             if (doLog) {
                 log.warn(msg);
-            } else if (log.isDebugEnabled()) {
+            } else if (log != null && log.isDebugEnabled()) {
+                // A null log is permitted by the constructor when 
warnOnFailure is false
                 log.debug(msg);
             }
             throw new InvalidClassException(msg);


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

Reply via email to