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/31 21:10:29 UTC
svn commit: r1670433 -
/tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java
Author: markt
Date: Tue Mar 31 19:10:29 2015
New Revision: 1670433
URL: http://svn.apache.org/r1670433
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=57765
File.lastModified() has a resolution of 1s (1000ms). The last modified time has to be more than 1000ms ago to ensure that modifications that take place in the same second are not missed.
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=1670433&r1=1670432&r2=1670433&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java Tue Mar 31 19:10:29 2015
@@ -1226,6 +1226,8 @@ public class HostConfig
protected synchronized void checkResources(DeployedApplication app) {
String[] resources =
app.redeployResources.keySet().toArray(new String[0]);
+ // Offset the current time by the resolution of File.lastModified()
+ long currentTimeWithResolutionOffset = System.currentTimeMillis() - 1000;
for (int i = 0; i < resources.length; i++) {
File resource = new File(resources[i]);
if (log.isDebugEnabled())
@@ -1234,7 +1236,12 @@ public class HostConfig
long lastModified =
app.redeployResources.get(resources[i]).longValue();
if (resource.exists() || lastModified == 0) {
- if (resource.lastModified() > lastModified) {
+ // File.lastModified() has a resolution of 1s (1000ms). The last
+ // modified time has to be more than 1000ms ago to ensure that
+ // modifications that take place in the same second are not
+ // missed. See Bug 57765.
+ if (resource.lastModified() > lastModified &&
+ resource.lastModified() < currentTimeWithResolutionOffset) {
if (resource.isDirectory()) {
// No action required for modified directory
app.redeployResources.put(resources[i],
@@ -1312,7 +1319,12 @@ public class HostConfig
log.debug("Checking context[" + app.name + "] reload resource " + resource);
}
long lastModified = app.reloadResources.get(resources[i]).longValue();
- if (resource.lastModified() != lastModified || update) {
+ // File.lastModified() has a resolution of 1s (1000ms). The last
+ // modified time has to be more than 1000ms ago to ensure that
+ // modifications that take place in the same second are not
+ // missed. See Bug 57765.
+ if ((resource.lastModified() != lastModified &&
+ resource.lastModified() < currentTimeWithResolutionOffset) || update) {
if (!update) {
// Reload application
reload(app);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org