You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2026/10/12 07:31:51 UTC
(tomcat) 08/14: Report a class name filter match failure via the documented exception when no Log is configured
This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit aa1df24935e34a4178809b6afa4c4134ddb964ab
Author: opencode <re...@apache.org>
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org