This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 894f69c8e8 Avoid NPE on Servlet exception unwrap
894f69c8e8 is described below
commit 894f69c8e81b39839eeaac873486c7932173084c
Author: remm <[email protected]>
AuthorDate: Fri Oct 24 12:39:33 2025 +0200
Avoid NPE on Servlet exception unwrap
BZ69862
It would add some exception details, but is not fatal.
Patch submitted by Eric Blanquer.
---
java/org/apache/jasper/servlet/JspServletWrapper.java | 6 ++++--
webapps/docs/changelog.xml | 4 ++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/jasper/servlet/JspServletWrapper.java
b/java/org/apache/jasper/servlet/JspServletWrapper.java
index 7d6122a130..a51f5caa55 100644
--- a/java/org/apache/jasper/servlet/JspServletWrapper.java
+++ b/java/org/apache/jasper/servlet/JspServletWrapper.java
@@ -516,8 +516,10 @@ public class JspServletWrapper {
protected JasperException handleJspException(Exception ex) {
try {
Throwable realException = ex;
- if (ex instanceof ServletException) {
- realException = ((ServletException) ex).getRootCause();
+ // Unwrap Servlet exception once
+ if (ex instanceof ServletException servletException
+ && servletException.getRootCause() != null) {
+ realException = servletException.getRootCause();
}
// Find the first stack frame that represents code generated by
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 7c9d5ff430..72dde4b4c4 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -252,6 +252,10 @@
<code>java.util.Date</code>. (markt)
</add>
<!-- Entries for backport and removal before 12.0.0-M1 below this line
-->
+ <fix>
+ <bug>69862</bug>: Avoid NPE unwrapping Servlet exception which would
+ hide some exception details. Patch submitted by Eric Blanquer. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Cluster">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]