This is an automated email from the ASF dual-hosted git repository. rmaucher pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit b82dd6e0414df3d4dbf8204a57c572e9c519cbb6 Author: opencode <[email protected]> AuthorDate: Mon Oct 19 16:39:20 2026 +0200 Avoid NullPointerException rendering a null entry Pushing null content to a FastRemovalDequeue was accepted but the Entry created for it rendered its content with a direct toString call, so converting the entry to a string failed with a null pointer exception. The JDK collections render a null element as the string null rather than failing, and the class javadoc treats the stored values as the caller's concern, so render the content with String.valueOf and pin the rendering of a null entry with a test. Found by code review. --- java/org/apache/jasper/util/FastRemovalDequeue.java | 2 +- test/org/apache/jasper/util/TestFastRemovalDequeue.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/java/org/apache/jasper/util/FastRemovalDequeue.java b/java/org/apache/jasper/util/FastRemovalDequeue.java index 35dfe2b436..1768ecc61b 100644 --- a/java/org/apache/jasper/util/FastRemovalDequeue.java +++ b/java/org/apache/jasper/util/FastRemovalDequeue.java @@ -323,7 +323,7 @@ public class FastRemovalDequeue<T> { @Override public String toString() { - return "Entry-" + content.toString(); + return "Entry-" + String.valueOf(content); } } diff --git a/test/org/apache/jasper/util/TestFastRemovalDequeue.java b/test/org/apache/jasper/util/TestFastRemovalDequeue.java index 237b571fef..5834dbf2da 100644 --- a/test/org/apache/jasper/util/TestFastRemovalDequeue.java +++ b/test/org/apache/jasper/util/TestFastRemovalDequeue.java @@ -241,6 +241,21 @@ public class TestFastRemovalDequeue { } + /* + * The rendering of an entry must tolerate null content, as the JDK + * collections render null elements, rather than fail with a null pointer + * exception. + */ + @Test + public void testNullContentToString() throws Exception { + FastRemovalDequeue<Object> q = new FastRemovalDequeue<>(2); + + FastRemovalDequeue<Object>.Entry e = q.push(null); + + Assert.assertEquals("Entry-null", e.toString()); + } + + /* * A maximum size below one cannot produce a usable queue and is * rejected, rather than silently replaced by a different size. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
