Author: markt
Date: Wed Feb 25 11:04:35 2015
New Revision: 1662197
URL: http://svn.apache.org/r1662197
Log:
Small optimisation for JSP compilation on first use.
Modified:
tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java
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=1662197&r1=1662196&r2=1662197&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java Wed Feb 25
11:04:35 2015
@@ -431,29 +431,30 @@ public abstract class Compiler {
jsw.setLastModificationTest(System.currentTimeMillis());
}
- Long jspRealLastModified = ctxt.getLastModified(ctxt.getJspFile());
- if (jspRealLastModified.longValue() < 0) {
- // Something went wrong - assume modification
- return true;
- }
-
- long targetLastModified = 0;
+ // Test the target file first. Unless there is an error checking the
+ // last modified time of the source (unlikely) the target is going to
+ // have to be checked anyway. If the target doesn't exist (likely
during
+ // startup) this saves an unnecessary check of the source.
File targetFile;
-
if (checkClass) {
targetFile = new File(ctxt.getClassFileName());
} else {
targetFile = new File(ctxt.getServletJavaFileName());
}
-
if (!targetFile.exists()) {
return true;
}
-
- targetLastModified = targetFile.lastModified();
+ long targetLastModified = targetFile.lastModified();
if (checkClass && jsw != null) {
jsw.setServletClassLastModifiedTime(targetLastModified);
}
+
+ Long jspRealLastModified = ctxt.getLastModified(ctxt.getJspFile());
+ if (jspRealLastModified.longValue() < 0) {
+ // Something went wrong - assume modification
+ return true;
+ }
+
if (targetLastModified != jspRealLastModified.longValue()) {
if (log.isDebugEnabled()) {
log.debug("Compiler: outdated: " + targetFile + " "
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]