You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2015/03/05 11:48:25 UTC

svn commit: r1664301 - /tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java

Author: markt
Date: Thu Mar  5 10:48:25 2015
New Revision: 1664301

URL: http://svn.apache.org/r1664301
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=56608
When deploying an external WAR, add watched resources in the expanded directory based on whether the expanded directory is expected to exist rather than if it does exist.
When triggering a reload due to a modified watched resource, ensure that multiple changed watched resources only trigger one reload rather than a series of reloads.

Modified:
    tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java

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=1664301&r1=1664300&r2=1664301&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java Thu Mar  5 10:48:25 2015
@@ -598,13 +598,14 @@ public class HostConfig
                 }
             }
 
+            boolean unpackWAR = unpackWARs;
+            if (unpackWAR && context instanceof StandardContext) {
+                unpackWAR = ((StandardContext) context).getUnpackWAR();
+            }
+
             // Add the eventual unpacked WAR and all the resources which will be
             // watched inside it
             if (isExternalWar) {
-                boolean unpackWAR = unpackWARs;
-                if (unpackWAR && context instanceof StandardContext) {
-                    unpackWAR = ((StandardContext) context).getUnpackWAR();
-                }
                 if (unpackWAR) {
                     deployedApp.redeployResources.put(expandedDocBase.getAbsolutePath(),
                             Long.valueOf(expandedDocBase.lastModified()));
@@ -626,7 +627,7 @@ public class HostConfig
                                 Long.valueOf(0));
                     }
                 }
-                if (expandedDocBase.exists()) {
+                if (unpackWAR) {
                     deployedApp.redeployResources.put(expandedDocBase.getAbsolutePath(),
                             Long.valueOf(expandedDocBase.lastModified()));
                     addWatchedResources(deployedApp,
@@ -634,8 +635,9 @@ public class HostConfig
                 } else {
                     addWatchedResources(deployedApp, null, context);
                 }
-                // Add the context XML to the list of files which should trigger a redeployment
                 if (!isExternal) {
+                    // For external docBases, the context.xml will have been
+                    // added above.
                     deployedApp.redeployResources.put(
                             contextXml.getAbsolutePath(),
                             Long.valueOf(contextXml.lastModified()));
@@ -1303,23 +1305,25 @@ public class HostConfig
             }
         }
         resources = app.reloadResources.keySet().toArray(new String[0]);
+        boolean update = false;
         for (int i = 0; i < resources.length; i++) {
             File resource = new File(resources[i]);
-            if (log.isDebugEnabled())
-                log.debug("Checking context[" + app.name +
-                        "] reload resource " + resource);
-            long lastModified =
-                app.reloadResources.get(resources[i]).longValue();
-            if ((!resource.exists() && lastModified != 0L)
-                || (resource.lastModified() != lastModified)) {
-                // Reload application
-                reload(app);
-                // Update times
+            if (log.isDebugEnabled()) {
+                log.debug("Checking context[" + app.name + "] reload resource " + resource);
+            }
+            long lastModified = app.reloadResources.get(resources[i]).longValue();
+            if (resource.lastModified() != lastModified || update) {
+                if (!update) {
+                    // Reload application
+                    reload(app);
+                    update = true;
+                }
+                // Update times. More than one file may have been updated. We
+                // don't want to trigger a series of reloads.
                 app.reloadResources.put(resources[i],
                         Long.valueOf(resource.lastModified()));
-                app.timestamp = System.currentTimeMillis();
-                return;
             }
+            app.timestamp = System.currentTimeMillis();
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org