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

remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 1c36837342ef90f0cf49fcabf6ab5fe799d87729
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                            | 8 ++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/jasper/servlet/JspServletWrapper.java 
b/java/org/apache/jasper/servlet/JspServletWrapper.java
index da8aeb1997..7094ba7cff 100644
--- a/java/org/apache/jasper/servlet/JspServletWrapper.java
+++ b/java/org/apache/jasper/servlet/JspServletWrapper.java
@@ -527,8 +527,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 524c792cef..b7ef61a495 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -121,6 +121,14 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="Jasper">
+    <changelog>
+      <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="Other">
     <changelog>
       <update>


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

Reply via email to