Workaround Java 6/7 bug described in https://issues.apache.org/bugzilla/show_bug...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 16 Feb 2010 00:46:07 +0000 (00:46 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 16 Feb 2010 00:46:07 +0000 (00:46 +0000)
Avoid the ArrayIndexOutOfBoundsException

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@910370 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/compiler/JavacErrorDetail.java
java/org/apache/jasper/resources/LocalStrings.properties

index 4071181..0dc3331 100644 (file)
@@ -96,6 +96,13 @@ public class JavacErrorDetail {
                 fis = new FileInputStream(ctxt.getServletJavaFileName());
                 String[] javaLines = readFile(fis);
     
+                if (jspLines.length < jspBeginLineNum) {
+                    // Avoid ArrayIndexOutOfBoundsException
+                    // Probably bug 48494 but could be some other cause
+                    jspExtract = Localizer.getMessage("jsp.error.bug48494");
+                    return;
+                }
+                
                 // If the line contains the opening of a multi-line scriptlet
                 // block, then the JSP line number we got back is probably
                 // faulty.  Scan forward to match the java line...
index d6ec183..4635013 100644 (file)
@@ -456,3 +456,6 @@ jsp.error.tag.conflict.trimdirectivewhitespaces=Tag directive: illegal to have m
 
 # JarScanner
 jsp.warning.noJarScanner=Warning: No org.apache.tomcat.JarScanner set in ServletContext. Falling back to default JarScanner implementation.
+
+# JavacErrorDetail
+jsp.error.bug48494=Unable to display JSP extract. Probably due to a JRE bug (see Tomcat bug 48498 for details).