From 10ca11d319880da4d77810a3097f00721425f05e Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 16 Feb 2010 00:46:07 +0000 Subject: [PATCH] Workaround Java 6/7 bug described in https://issues.apache.org/bugzilla/show_bug.cgi?id=48498 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 | 7 +++++++ java/org/apache/jasper/resources/LocalStrings.properties | 3 +++ 2 files changed, 10 insertions(+) diff --git a/java/org/apache/jasper/compiler/JavacErrorDetail.java b/java/org/apache/jasper/compiler/JavacErrorDetail.java index 40711813a..0dc333159 100644 --- a/java/org/apache/jasper/compiler/JavacErrorDetail.java +++ b/java/org/apache/jasper/compiler/JavacErrorDetail.java @@ -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... diff --git a/java/org/apache/jasper/resources/LocalStrings.properties b/java/org/apache/jasper/resources/LocalStrings.properties index d6ec183b9..46350137c 100644 --- a/java/org/apache/jasper/resources/LocalStrings.properties +++ b/java/org/apache/jasper/resources/LocalStrings.properties @@ -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). -- 2.11.0