Skip to content

Files created on 1970-01-01 0000.0 are never copied when the target is not present. #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

AndreasKl
Copy link

@AndreasKl AndreasKl commented Apr 25, 2018

This issue occurred to me when copying javascript from a node module.

These files were created on 1970-01-01 : 0000.00 and were not copied by the maven-resources-plugin. I was able to track the issue down to the:

public static void copyFile( File from, File to, String encoding, FilterWrapper[] wrappers, boolean overwrite ) public static void copyFile( File from, File to, String encoding, FilterWrapper[] wrappers, boolean overwrite ) throws IOException

method.

The behaviour can be emulated with touch -t 197001010000.00 test-1970-01-01.txt.

The root cause is https://docs.oracle.com/javase/7/docs/api/java/io/File.html#lastModified()

...or 0L if the file does not exist or if an I/O error occurs...

In this case the lastModified of the source file is equal to the lastModified of the non existing target file.

@michael-o
Copy link
Member

WTF, stupid return values. So one does never know wether it is really 0L or bogus 0L.

@AndreasKl
Copy link
Author

@michael-o I was really surprised that this behaviour exists since Java 1.0. I could have called file exists in the fix but was unsure about the performance impact e.g. if the source is on a remote system with high latency.

@AndreasKl
Copy link
Author

AndreasKl commented May 22, 2018

@michael-o @khmarbaise is there anything I can do to get this PR merged?

@michael-o michael-o self-assigned this May 22, 2018
@michael-o
Copy link
Member

michael-o commented May 22, 2018

Thanks for the ping, I completely forgot that. Will merge this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants