Jar content files has future date
Jars downloaded from mvnrepository (https://mvnrepository.com/artifact/org.typelevel/spire) have future modified date.

This causing AWS EMR Step to fail because during unJar operation it checks for this value Here is a code snippet from hadoop.
public static void unJar(InputStream inputStream, File toDir,
Pattern unpackRegex)
throws IOException {
try (JarInputStream jar = new JarInputStream(inputStream)) {
int numOfFailedLastModifiedSet = 0;
String targetDirPath = toDir.getCanonicalPath() + File.separator;
for (JarEntry entry = jar.getNextJarEntry();
entry != null;
entry = jar.getNextJarEntry()) {
if (!entry.isDirectory() &&
unpackRegex.matcher(entry.getName()).matches()) {
File file = new File(toDir, entry.getName());
if (!file.getCanonicalPath().startsWith(targetDirPath)) {
throw new IOException("expanding " + entry.getName()
+ " would create file outside of " + toDir);
}
ensureDirectory(file.getParentFile());
try (OutputStream out = Files.newOutputStream(file.toPath())) {
IOUtils.copyBytes(jar, out, BUFFER_SIZE);
}
if (!file.setLastModified(entry.getTime())) {
numOfFailedLastModifiedSet++;
}
}
}
if (numOfFailedLastModifiedSet > 0) {
LOG.warn("Could not set last modfied time for {} file(s)",
numOfFailedLastModifiedSet);
}
// ZipInputStream does not need the end of the file. Let's read it out.
// This helps with an additional TeeInputStream on the input.
IOUtils.copyBytes(inputStream, new NullOutputStream(), BUFFER_SIZE);
}
}
Here is a link to hadoop https://github.com/apache/hadoop/blob/f6fa5bd1aa085a4d22f3450b545bb70063da9f51/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/RunJar.java#L115
Exception in thread "main" java.lang.IllegalArgumentException: Negative time
at java.base/java.io.File.setLastModified(File.java:1478)
at org.apache.hadoop.util.RunJar.unJar(RunJar.java:206)
at org.apache.hadoop.util.RunJar.unJar(RunJar.java:101)
at org.apache.hadoop.util.RunJar.run(RunJar.java:310)
at org.apache.hadoop.util.RunJar.main(RunJar.java:236)
When I excluded all spire libraries from jar AWS EMR Step passed .
I noticed that version 0.18.0 has a correct modified date in past but unfortunately it's difficult for me to update to scala 2.13.
Also complete exlusion is not a safe solution. I tested exclusion of the artifacts only to confirm this.
Thanks for the report. Unfortunately I cannot reproduce it.
$ wget https://repo1.maven.org/maven2/org/typelevel/spire_2.12/0.17.0/spire_2.12-0.17.0.jar
--2022-08-24 20:59:24-- https://repo1.maven.org/maven2/org/typelevel/spire_2.12/0.17.0/spire_2.12-0.17.0.jar
Resolving repo1.maven.org (repo1.maven.org)... 199.232.192.209, 199.232.196.209
Connecting to repo1.maven.org (repo1.maven.org)|199.232.192.209|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7243903 (6.9M) [application/java-archive]
Saving to: ‘spire_2.12-0.17.0.jar’
spire_2.12-0.17.0.ja 100%[====================>] 6.91M --.-KB/s in 0.06s
2022-08-24 20:59:24 (119 MB/s) - ‘spire_2.12-0.17.0.jar’ saved [7243903/7243903]
$ unzip spire_2.12-0.17.0.jar
...
inflating: spire/syntax/std/package.class
$ ls -l spire
total 888
drwxr-xr-x 5 gitpod gitpod 12288 Jan 1 1980 algebra
-rw-r--r-- 1 gitpod gitpod 2486 Jan 1 1980 'BuildInfo$.class'
-rw-r--r-- 1 gitpod gitpod 1783 Jan 1 1980 BuildInfo.class
-rw-r--r-- 1 gitpod gitpod 3834 Jan 1 1980 'compat$.class'
-rw-r--r-- 1 gitpod gitpod 2380 Jan 1 1980 compat.class
-rw-r--r-- 1 gitpod gitpod 9397 Jan 1 1980 'CompatPriority1$$anon$1.class'
-rw-r--r-- 1 gitpod gitpod 4535 Jan 1 1980 'CompatPriority1$$anon$2.class'
-rw-r--r-- 1 gitpod gitpod 2869 Jan 1 1980 'CompatPriority1$$anon$3.class'
-rw-r--r-- 1 gitpod gitpod 1485 Jan 1 1980 'CompatPriority1$$anon$4.class'
-rw-r--r-- 1 gitpod gitpod 4031 Jan 1 1980 CompatPriority1.class
-rw-r--r-- 1 gitpod gitpod 9741 Jan 1 1980 'CompatPriority2$$anon$5.class'
-rw-r--r-- 1 gitpod gitpod 2143 Jan 1 1980 CompatPriority2.class
-rw-r--r-- 1 gitpod gitpod 9923 Jan 1 1980 'CompatPriority3$$anon$6.class'
-rw-r--r-- 1 gitpod gitpod 2182 Jan 1 1980 CompatPriority3.class
-rw-r--r-- 1 gitpod gitpod 421371 Jan 1 1980 'implicits$.class'
-rw-r--r-- 1 gitpod gitpod 246045 Jan 1 1980 implicits.class
drwxr-xr-x 3 gitpod gitpod 4096 Jan 1 1980 macros
drwxr-xr-x 5 gitpod gitpod 20480 Jan 1 1980 math
-rw-r--r-- 1 gitpod gitpod 856 Jan 1 1980 'NoImplicit$.class'
-rw-r--r-- 1 gitpod gitpod 1201 Jan 1 1980 NoImplicit.class
drwxr-xr-x 3 gitpod gitpod 4096 Jan 1 1980 optional
-rw-r--r-- 1 gitpod gitpod 596 Jan 1 1980 'package$.class'
-rw-r--r-- 1 gitpod gitpod 764 Jan 1 1980 package.class
drwxr-xr-x 3 gitpod gitpod 8192 Jan 1 1980 random
drwxr-xr-x 2 gitpod gitpod 186 Jan 1 1980 scalacompat
drwxr-xr-x 2 gitpod gitpod 45056 Jan 1 1980 std
drwxr-xr-x 3 gitpod gitpod 12288 Jan 1 1980 syntax
$ stat spire/package\$.class
File: spire/package$.class
Size: 596 Blocks: 8 IO Block: 4096 regular file
Device: 92ah/2346d Inode: 4026593269 Links: 1
Access: (0644/-rw-r--r--) Uid: (33333/ gitpod) Gid: (33333/ gitpod)
Access: 1980-01-01 00:00:00.000000000 +0000
Modify: 1980-01-01 00:00:00.000000000 +0000
Change: 2022-08-24 21:00:21.179664842 +0000
Birth: -
Indeed. When I try your use case in WSL I get same results as you.
When unzipping in windows I get this.

I tried to run similar code what Hadoop has.
When running with corretto 11 it returns negative value, it stopped on breakpoint

When using corretto 8 it passes without problems.
Here is a code (it uses only java classes, no library needed, so it's safe)
File jarFile = new File("path\\Downloads\\spire_2.12-0.17.0.jar");
try (JarFile jar = new JarFile(jarFile)) {
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
final JarEntry entry = entries.nextElement();
if (!entry.isDirectory()) {
try (InputStream in = jar.getInputStream(entry)) {
if (entry.getTime() < 0) {
System.out.println("Why tho!" + entry.getName());
}
}
}
}
}
Thanks for the additional details. Since you were able to replicate my results, I'm not sure what more we can do here—seems like this may be a bug/inconsistent behavior between zip tooling/libraries.
We cannot re-publish 0.17.0 anyway. You can try cloning the repository at that tag, building from source, and publishing yourself. But it's not obvious to me if this will fix the problem (it may depend on which JDK you use!).
See also https://en.wikipedia.org/wiki/Time_formatting_and_storage_bugs#Year_2106