Author: markt Date: Thu May 19 16:25:45 2011 New Revision: 1124986 URL: http://svn.apache.org/viewvc?rev=1124986&view=rev Log: Refactoring in preparation for a fix for BZ 33453
Modified: tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties Modified: tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java?rev=1124986&r1=1124985&r2=1124986&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java (original) +++ tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java Thu May 19 16:25:45 2011 @@ -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; } Modified: tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java?rev=1124986&r1=1124985&r2=1124986&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java Thu May 19 16:25:45 2011 @@ -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; } Modified: tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties?rev=1124986&r1=1124985&r2=1124986&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties Thu May 19 16:25:45 2011 @@ -454,6 +454,7 @@ jsp.error.nested_jsproot=Nested <jsp: 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 JS 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 --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org