Skip to content
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

Timestamps are not preserved when copying app into container #130

Closed
jkutner opened this issue Mar 30, 2019 · 1 comment
Closed

Timestamps are not preserved when copying app into container #130

jkutner opened this issue Mar 30, 2019 · 1 comment
Assignees
Milestone

Comments

@jkutner
Copy link
Member

jkutner commented Mar 30, 2019

When local files (from --path) are copied into the container, they get a last-modified timestamp of 1970-01-01 00:00:00 instead of preserving the timestamp from local.

This causes a problem with spring-boot, which tries to validate the files in an executable JAR file before starting:

Exception in thread "main" java.time.DateTimeException: Invalid value for MonthOfYear (valid values 1 - 12): 0
        at java.time.temporal.ValueRange.checkValidValue(ValueRange.java:311)
        at java.time.temporal.ChronoField.checkValidValue(ChronoField.java:703)
        at java.time.LocalDate.of(LocalDate.java:267)
        at java.time.LocalDateTime.of(LocalDateTime.java:336)
        at org.springframework.boot.loader.jar.CentralDirectoryFileHeader.decodeMsDosFormatDateTime(CentralDirectoryFileHeader.java:130)
        at org.springframework.boot.loader.jar.CentralDirectoryFileHeader.getTime(CentralDirectoryFileHeader.java:119)
        at org.springframework.boot.loader.jar.JarEntry.<init>(JarEntry.java:55)
        at org.springframework.boot.loader.jar.JarFileEntries.getEntry(JarFileEntries.java:328)
        at org.springframework.boot.loader.jar.JarFileEntries.access$400(JarFileEntries.java:48)
        at org.springframework.boot.loader.jar.JarFileEntries$EntryIterator.next(JarFileEntries.java:379)
        at org.springframework.boot.loader.jar.JarFileEntries$EntryIterator.next(JarFileEntries.java:363)
        at org.springframework.boot.loader.jar.JarFile$2.nextElement(JarFile.java:198)
        at org.springframework.boot.loader.jar.JarFile$2.nextElement(JarFile.java:189)
        at org.springframework.boot.loader.archive.JarFileArchive$EntryIterator.next(JarFileArchive.java:186)
        at org.springframework.boot.loader.archive.JarFileArchive$EntryIterator.next(JarFileArchive.java:171)
        at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:84)
        at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:70)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:49)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)

The first file that triggers this is usually META-INF/maven/com.example/java-getting-started/pom.xml, which is the first file the Spring ExecutableArchiveLauncher hits with a timestamp of 1970-01-01 00:00:00

djoyahoy pushed a commit to buildpacks/lifecycle that referenced this issue Apr 1, 2019
* This prevents an issue where certain versions of the jdk
  cannot parse jar file creation times

[buildpacks/pack#130]

Signed-off-by: Danny Joyce <djoyce@pivotal.io>
Signed-off-by: Andrew Meyer <ameyer@pivotal.io>
djoyahoy pushed a commit that referenced this issue Apr 1, 2019
* This prevents an issue where certain versions of the jdk
  cannot parse jar file creation times

[#130]

Signed-off-by: Danny Joyce <djoyce@pivotal.io>
Signed-off-by: Andrew Meyer <ameyer@pivotal.io>
@djoyahoy
Copy link
Member

djoyahoy commented Apr 1, 2019

@jkutner We ended up writing all file times at January 1, 1980 00:00:1. This is because zip files (jars) use MS-DOS format for their file times and the epoch for those is Jan 1, 1980. This prevents a cascading failure with the JDK as noted here: https://bugs.openjdk.java.net/browse/JDK-8184940

Additionally, we wanted to stick to a known date and time for all files with an aim towards reproducible builds.

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

No branches or pull requests

4 participants