-
Notifications
You must be signed in to change notification settings - Fork 41.7k
Closed
Labels
status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by another
Description
When the system time to package compilation environment is date 1970,the jar will run error:
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:127)
at org.springframework.boot.loader.jar.CentralDirectoryFileHeader.getTime(CentralDirectoryFileHeader.java:116)
at org.springframework.boot.loader.jar.JarEntry.<init>(JarEntry.java:58)
at org.springframework.boot.loader.jar.JarFileEntries.getEntry(JarFileEntries.java:316)
at org.springframework.boot.loader.jar.JarFileEntries.access$400(JarFileEntries.java:48)
at org.springframework.boot.loader.jar.JarFileEntries$EntryIterator.next(JarFileEntries.java:366)
at org.springframework.boot.loader.jar.JarFileEntries$EntryIterator.next(JarFileEntries.java:350)
at org.springframework.boot.loader.jar.JarFile$2.nextElement(JarFile.java:204)
at org.springframework.boot.loader.jar.JarFile$2.nextElement(JarFile.java:195)
at org.springframework.boot.loader.archive.JarFileArchive$EntryIterator.next(JarFileArchive.java:189)
at org.springframework.boot.loader.archive.JarFileArchive$EntryIterator.next(JarFileArchive.java:174)
at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:85)
at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:69)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
I find this is a bub, in CentralDirectoryFileHeader.decodeMsDosFormatDateTime when date is 1970, then date is 0,
like date is
“Thu Jan 01 08:00:00 GMT+08:00 1970”
long datetime is 0
so
private long decodeMsDosFormatDateTime(long datetime) {
LocalDateTime localDateTime = LocalDateTime.of(
(int) (((datetime >> 25) & 0x7f) + 1980), (int) ((datetime >> 21) & 0x0f),
(int) ((datetime >> 16) & 0x1f), (int) ((datetime >> 11) & 0x1f),
(int) ((datetime >> 5) & 0x3f), (int) ((datetime << 1) & 0x3e));
return localDateTime.toEpochSecond(
ZoneId.systemDefault().getRules().getOffset(localDateTime)) * 1000;
}then year is 1980 ,month is 0 for jdk check month is error 0,so throw “Invalid value for MonthOfYear (valid values 1 - 12): 0”
Metadata
Metadata
Assignees
Labels
status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by another