From: markt Date: Thu, 19 May 2011 16:25:45 +0000 (+0000) Subject: Refactoring in preparation for a fix for BZ 33453 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=7b67d4f48f1b13dd1b965f2c0afc95eb87fd606f;p=tomcat7.0 Refactoring in preparation for a fix for BZ 33453 git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1124986 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/jasper/JspCompilationContext.java b/java/org/apache/jasper/JspCompilationContext.java index 274db1059..ec05e0b29 100644 --- a/java/org/apache/jasper/JspCompilationContext.java +++ b/java/org/apache/jasper/JspCompilationContext.java @@ -19,9 +19,12 @@ package org.apache.jasper; import java.io.File; import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.JarURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.net.URLConnection; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -382,6 +385,43 @@ public class JspCompilationContext { return jspUri; } + public long getJspLastModified() { + long result = -1; + URLConnection uc = null; + try { + URL jspUrl = getResource(getJspFile()); + if (jspUrl == null) { + incrementRemoved(); + return result; + } + uc = jspUrl.openConnection(); + if (uc instanceof JarURLConnection) { + result = ((JarURLConnection) uc).getJarEntry().getTime(); + } else { + result = uc.getLastModified(); + } + } catch (IOException e) { + if (log.isDebugEnabled()) { + log.debug(Localizer.getMessage( + "jsp.error.lastModified", getJspFile()), e); + } + result = -1; + } finally { + if (uc != null) { + try { + uc.getInputStream().close(); + } catch (IOException e) { + if (log.isDebugEnabled()) { + log.debug(Localizer.getMessage( + "jsp.error.lastModified", getJspFile()), e); + } + result = -1; + } + } + } + return result; + } + public boolean isTagFile() { return isTagFile; } diff --git a/java/org/apache/jasper/compiler/Compiler.java b/java/org/apache/jasper/compiler/Compiler.java index 4b9add497..1f8959545 100644 --- a/java/org/apache/jasper/compiler/Compiler.java +++ b/java/org/apache/jasper/compiler/Compiler.java @@ -429,8 +429,6 @@ public abstract class Compiler { */ public boolean isOutDated(boolean checkClass) { - String jsp = ctxt.getJspFile(); - if (jsw != null && (ctxt.getOptions().getModificationTestInterval() > 0)) { @@ -442,24 +440,9 @@ public abstract class Compiler { jsw.setLastModificationTest(System.currentTimeMillis()); } - long jspRealLastModified = 0; - try { - URL jspUrl = ctxt.getResource(jsp); - if (jspUrl == null) { - ctxt.incrementRemoved(); - return true; - } - URLConnection uc = jspUrl.openConnection(); - if (uc instanceof JarURLConnection) { - jspRealLastModified = - ((JarURLConnection) uc).getJarEntry().getTime(); - } else { - jspRealLastModified = uc.getLastModified(); - } - uc.getInputStream().close(); - } catch (Exception e) { - if (log.isDebugEnabled()) - log.debug("Problem accessing resource. Treat as outdated.", e); + long jspRealLastModified = ctxt.getJspLastModified(); + if (jspRealLastModified < 0) { + // Something went wrong - assume modification return true; } diff --git a/java/org/apache/jasper/resources/LocalStrings.properties b/java/org/apache/jasper/resources/LocalStrings.properties index 50dbfb55e..74569c61e 100644 --- a/java/org/apache/jasper/resources/LocalStrings.properties +++ b/java/org/apache/jasper/resources/LocalStrings.properties @@ -454,6 +454,7 @@ jsp.error.nested_jsproot=Nested <jsp:root> jsp.error.unbalanced.endtag=The end tag \"</{0}\" is unbalanced jsp.error.invalid.bean=The value for the useBean class attribute {0} is invalid. jsp.error.prefix.use_before_dcl=The prefix {0} specified in this tag directive has been previously used by an action in file {1} line {2}. +jsp.error.lastModified=Unable to determine last modified date for file [{0}] jsp.exception=An exception occurred processing JSP page {0} at line {1} @@ -489,4 +490,4 @@ jsp.message.jsp_unload_check=Checking JSPs for unload in context [{0}], JSP coun xmlParser.skipBomFail=Failed to skip BOM when parsing XML input stream -jsp.tldCache.noTldInJar=No TLD files were found in [{0}]. Consider adding the JAR to to the tomcat.util.scan.DefaultJarScanner.jarsToSkip in CATALINA_BASE/catalina.properties \ No newline at end of file +jsp.tldCache.noTldInJar=No TLD files were found in [{0}]. Consider adding the JAR to to the tomcat.util.scan.DefaultJarScanner.jarsToSkip in CATALINA_BASE/catalina.properties