2015-04-01 0:09 GMT+03:00 Konstantin Kolinko <knst.koli...@gmail.com>:
> 2015-03-31 22:15 GMT+03:00  <ma...@apache.org>:
>> Author: markt
>> Date: Tue Mar 31 19:15:48 2015
>> New Revision: 1670437
>>
>> URL: http://svn.apache.org/r1670437
>> 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.
>
> IIRC,  file modification time on FAT file system has resolution of 2s,
>
> https://msdn.microsoft.com/en-us/library/windows/desktop/ms724290%28v=vs.85%29.aspx

The following tests are failing with Tomcat 7,
TEST-org.apache.catalina.startup.TestHostConfigAutomaticDeployment.BIO.txt
TEST-org.apache.catalina.startup.TestHostConfigAutomaticDeployment.NIO.txt

and are also failing in trunk (NIO, NIO2 there).


>> Modified:
>>     tomcat/tc7.0.x/trunk/   (props changed)
>>     tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java
>>     tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
>>
>>
>> Modified: 
>> tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java?rev=1670437&r1=1670436&r2=1670437&view=diff
>> ==============================================================================
>> --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java 
>> (original)
>> +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java 
>> Tue Mar 31 19:15:48 2015
>> @@ -1388,6 +1388,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())
>> @@ -1396,7 +1398,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],
>> @@ -1473,7 +1480,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);
>>
>> Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1670437&r1=1670436&r2=1670437&view=diff
>> ==============================================================================
>> --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
>> +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Mar 31 19:15:48 2015
>> @@ -62,6 +62,13 @@
>>          Allow logging of the remote port in the access log using the format
>>          pattern <code>%{remote}p</code>. (rjung)
>>        </add>
>> +      <fix>
>> +        <bug>57765</bug>: When checking last modified times as part of the
>> +        automatic deployment process, account for the fact that
>> +        <code>File.lastModified()</code> has a resolution of one second to
>> +        ensure that if a file has been modified within the last second, the
>> +        latest version of the file is always used. (markt)
>> +      </fix>
>>      </changelog>
>>    </subsection>

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

Reply via email to