jdelker opened a new issue, #684:
URL: https://github.com/apache/maven-war-plugin/issues/684

   ### Affected version
   
   3.5.1, possibly others
   
   ### Bug description
   
   While analysing a weird race-condition during WAR packaging, I might have 
discovered the responsible cause.
   
   Symptom: On some builds, the WAR is badly packaged because modified files 
are not copied from the overlay to the target directory.
   This seems to happen, when the overlay file has the same modify time as the 
target, although having been changed in the build process.
   
   Analysis showed, that the modified overlay file is sometimes not copied, 
because **the modification time is the same as the target file**, although the 
file content differs.
   Digging deeper revealed, that the modification timestamp has a granularity 
of 1 sec on the underlying filesystem (Apple HFS). So when the file 
modification and packaging actually run within a second, the file copy might be 
surpressed!
   
   Responsible for that seems this method in `AbstractWarPackagingTask`:
   ```
   protected boolean copyFile(
               WarPackagingContext context, File source, File destination, 
String targetFilename, boolean onlyIfModified)
               throws IOException {
           context.addResource(targetFilename);
   
           BasicFileAttributes readAttributes = 
Files.readAttributes(source.toPath(), BasicFileAttributes.class);
           if (onlyIfModified
                   && destination.lastModified()
                           >= readAttributes.lastModifiedTime().toMillis()) {
               context.getLog().debug(" * " + targetFilename + " is up to 
date.");
               return false;
           } else {
   ...
   ```
   Although the `lastModifiedTime` attribute is compared in millis, it 
effectively only compares in seconds, when the underlying FS hasn't that 
granularity. This even disregards a difference in file size.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to