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/18 15:50:44 UTC

svn commit: r1667565 - in /tomcat/tc6.0.x/trunk: STATUS.txt java/org/apache/catalina/startup/HostConfig.java webapps/docs/changelog.xml

Author: markt
Date: Wed Mar 18 14:50:43 2015
New Revision: 1667565

URL: http://svn.apache.org/r1667565
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=56608
Watched resources should be tracked if they are expected to exist even if they don't exist when the Context starts
Also prevent multiple changes at the same time triggering multiple reloads rather than just one

Modified:
    tomcat/tc6.0.x/trunk/STATUS.txt
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1667565&r1=1667564&r2=1667565&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Wed Mar 18 14:50:43 2015
@@ -53,15 +53,6 @@ PATCHES PROPOSED TO BACKPORT:
        (e.g. search for "ecj-4.3.1.jar"), and do not skip jstl.jar.)
 
 
-* Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=56608
-  Watched resources should be tracked if they are expected to exist even if they
-  don't exist when the Context starts
-  Also prevent multiple changes at the same time triggering multiple reloads
-  rather than just one
-  http://people.apache.org/~markt/patches/2015-03-05-bug56608-tc6-v1.patch
-  +1: markt, schultz, remm
-  -1:
-
 * Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=57675
   Correctly quote strings when using the extended access log
   http://svn.apache.org/r1665087

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java?rev=1667565&r1=1667564&r2=1667565&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java Wed Mar 18 14:50:43 2015
@@ -712,7 +712,7 @@ public class HostConfig
                                 new Long(warDocBase.lastModified()));
                     }
                 }
-                if (expandedDocBase.exists()) {
+                if (unpackWARs) {
                     deployedApp.redeployResources.put(expandedDocBase.getAbsolutePath(),
                             new Long(expandedDocBase.lastModified()));
                     addWatchedResources(deployedApp,
@@ -1261,36 +1261,41 @@ 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())
+            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
-                if(log.isInfoEnabled())
-                    log.info(sm.getString("hostConfig.reload", app.name));
-                Container context = host.findChild(app.name);
-                try {
-                    ((Lifecycle) context).stop();
-                } catch (Exception e) {
-                    log.warn(sm.getString
-                             ("hostConfig.context.restart", app.name), e);
-                }
-                // If the context was not started (for example an error
-                // in web.xml) we'll still get to try to start
-                try {
-                    ((Lifecycle) context).start();
-                } catch (Exception e) {
-                    log.warn(sm.getString
-                             ("hostConfig.context.restart", app.name), e);
+            if (resource.lastModified() != lastModified || update) {
+                if (!update) {
+                    // Reload application
+                    if(log.isInfoEnabled()) {
+                        log.info(sm.getString("hostConfig.reload", app.name));
+                    }
+                    Container context = host.findChild(app.name);
+                    try {
+                        ((Lifecycle) context).stop();
+                    } catch (Exception e) {
+                        log.warn(sm.getString
+                                 ("hostConfig.context.restart", app.name), e);
+                    }
+                    // If the context was not started (for example an error
+                    // in web.xml) we'll still get to try to start
+                    try {
+                        ((Lifecycle) context).start();
+                    } catch (Exception e) {
+                        log.warn(sm.getString
+                                 ("hostConfig.context.restart", app.name), e);
+                    }
+                    update = true;
                 }
-                // Update times
-                app.reloadResources.put(resources[i], new Long(resource.lastModified()));
-                app.timestamp = System.currentTimeMillis();
-                return;
+                // 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();
         }
     }
 

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1667565&r1=1667564&r2=1667565&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Wed Mar 18 14:50:43 2015
@@ -317,6 +317,16 @@
         variables. Be more strict with executable filename on Windows
         (s/java/java.exe/). Based on a patch by Neeme Praks. (markt/kkolinko)
       </add>
+      <fix>
+        <bug>56608</bug>: 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.
+      </fix>
+      <fix>
+         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.
+      </fix>
     </changelog>
   </subsection>
 </section>



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