Author: markt Date: Tue Mar 3 20:03:29 2015 New Revision: 1663772 URL: http://svn.apache.org/r1663772 Log: Additional follow-up to r1663715 - Use a Tomcat specific file located in META-INF to track the WAR modification time rather than using the expanded directory - If the use expands the directory themselves, this tracking mechanism won;t be used.
Modified: tomcat/trunk/java/org/apache/catalina/startup/Constants.java tomcat/trunk/java/org/apache/catalina/startup/ExpandWar.java tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java Modified: tomcat/trunk/java/org/apache/catalina/startup/Constants.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/Constants.java?rev=1663772&r1=1663771&r2=1663772&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/startup/Constants.java (original) +++ tomcat/trunk/java/org/apache/catalina/startup/Constants.java Tue Mar 3 20:03:29 2015 @@ -31,6 +31,7 @@ public final class Constants { public static final String DefaultWebXml = "conf/web.xml"; public static final String HostContextXml = "context.xml.default"; public static final String HostWebXml = "web.xml.default"; + public static final String WarTracker = "/META-INF/war-tracker"; /** * A dummy value used to suppress loading the default web.xml file. Modified: tomcat/trunk/java/org/apache/catalina/startup/ExpandWar.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ExpandWar.java?rev=1663772&r1=1663771&r2=1663772&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/startup/ExpandWar.java (original) +++ tomcat/trunk/java/org/apache/catalina/startup/ExpandWar.java Tue Mar 3 20:03:29 2015 @@ -80,6 +80,7 @@ public class ExpandWar { // Set up the variables used in the finally block of the following try boolean success = false; File docBase = new File(host.getAppBaseFile(), pathname); + File warTracker = new File(host.getAppBaseFile(), pathname + Constants.WarTracker); try (JarFile jarFile = juc.getJarFile()) { @@ -92,10 +93,9 @@ public class ExpandWar { // time of the expanded directory to the last modified time of // the WAR so changes to the WAR while Tomcat is stopped can be // detected - long dirLastModified = docBase.lastModified(); - - if (dirLastModified == warLastModified) { - // No changes to the WAR + if (!warTracker.exists() || warTracker.lastModified() == warLastModified) { + // No (detectable) changes to the WAR + success = true; return (docBase.getAbsolutePath()); } @@ -157,9 +157,10 @@ public class ExpandWar { } } - // Align the last modified time of the directory with the WAR so - // changes to the WAR while Tomcat is stopped can be detected - docBase.setLastModified(warLastModified); + // Create the warTracker file and align the last modified time + // with the last modified time of the WAR + warTracker.createNewFile(); + warTracker.setLastModified(warLastModified); } success = true; } catch (IOException e) { Modified: tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java?rev=1663772&r1=1663771&r2=1663772&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java (original) +++ tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java Tue Mar 3 20:03:29 2015 @@ -776,6 +776,9 @@ public class HostConfig File xml = new File(host.getAppBaseFile(), cn.getBaseName() + "/" + Constants.ApplicationContextXml); + File warTracker = new File(host.getAppBaseFile(), + cn.getBaseName() + "/" + Constants.WarTracker); + boolean xmlInWar = false; JarEntry entry = null; try (JarFile jar = new JarFile(war)) { @@ -793,10 +796,10 @@ public class HostConfig // should only be used if the directory is not out of date and // unpackWARs is true. Note the code below may apply further limits boolean useXml = false; - File expandedDir = new File(host.getAppBaseFile(), cn.getBaseName()); // If the xml file exists then expandedDir must exists so no need to // test that here - if (xml.exists() && unpackWARs && expandedDir.lastModified() == war.lastModified()) { + if (xml.exists() && unpackWARs && + (!warTracker.exists() || warTracker.lastModified() == war.lastModified())) { useXml = true; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org