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

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

commit f2706e6e9773457e696e38a403115fbfc3d9d029
Author: opencode <[email protected]>
AuthorDate: Sun Oct 18 21:55:48 2026 +0200

    Correct the "unusable error detail" line number in JavacErrorDetail
    
    When the generated Java source belongs to an earlier, shorter
    compilation of the JSP page, the constructor returns early from the
    truncation guard introduced in r1725278, which predates the
    field-assignment refactoring and left this.jspBeginLineNum at 0. Since
    -1 is the value the API uses to mark an error detail as unusable (both
    other constructor exits follow this convention, and callers such as
    JspServletWrapper.handleJspException and Validator already treat -1 as
    "no usable location"), leave it at -1 on this path as well.
    Clarify the comment describing when and how the field is assigned.
---
 java/org/apache/jasper/compiler/JavacErrorDetail.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/jasper/compiler/JavacErrorDetail.java 
b/java/org/apache/jasper/compiler/JavacErrorDetail.java
index eef5f57205..158425a4dc 100644
--- a/java/org/apache/jasper/compiler/JavacErrorDetail.java
+++ b/java/org/apache/jasper/compiler/JavacErrorDetail.java
@@ -69,7 +69,10 @@ public class JavacErrorDetail {
         this.errMsg = errMsg;
         this.jspFileName = jspFileName;
         // Note: this.jspBeginLineNum is set at the end of this method as it 
may
-        // be modified (corrected) during the execution of this method
+        // be modified (corrected) during the execution of this method. It is
+        // left at -1, which marks the error detail as unusable, if the
+        // generated Java source turns out to belong to a different compilation
+        // of the JSP page.
 
         if (jspBeginLineNum > 0 && ctxt != null) {
             InputStream is = null;
@@ -99,6 +102,9 @@ public class JavacErrorDetail {
                         // Avoid ArrayIndexOutOfBoundsException
                         // Probably bug 48498 but could be some other cause
                         jspExtract = 
Localizer.getMessage("jsp.error.bug48498");
+                        // Report only the Java line, since the JSP line
+                        // cannot be validated against the truncated source
+                        this.jspBeginLineNum = -1;
                         return;
                     }
 


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

Reply via email to