diff --git a/src/main/java/cpw/mods/jarhandling/impl/JarContentsImpl.java b/src/main/java/cpw/mods/jarhandling/impl/JarContentsImpl.java index a39807b8..b9647698 100644 --- a/src/main/java/cpw/mods/jarhandling/impl/JarContentsImpl.java +++ b/src/main/java/cpw/mods/jarhandling/impl/JarContentsImpl.java @@ -115,6 +115,8 @@ private Map readMultiReleaseInfo() { } var vers = filesystem.getRoot().resolve("META-INF/versions"); + if (!Files.isDirectory(vers)) return Map.of(); + try (var walk = Files.walk(vers)) { Map pathToJavaVersion = new HashMap<>(); walk diff --git a/src/test/java/cpw/mods/jarhandling/impl/TestMultiRelease.java b/src/test/java/cpw/mods/jarhandling/impl/TestMultiRelease.java index bf5592c2..5e0848d6 100644 --- a/src/test/java/cpw/mods/jarhandling/impl/TestMultiRelease.java +++ b/src/test/java/cpw/mods/jarhandling/impl/TestMultiRelease.java @@ -28,6 +28,13 @@ public void testMultiRelease() { Assertions.assertNotEquals("too new", bContents.strip()); } + @Test + public void testMultiReleaseNoVersions() { + Path rootDir = Paths.get("src", "test", "resources", "multirelease-noversions"); + // Jars marked with Multi-Release but don't actually have a versions folder should not throw + Assertions.assertDoesNotThrow(() -> SecureJar.from(rootDir)); + } + private static String readString(SecureJar jar, String file) { // Note: we must read the jar through the module data provider for version-specific files to be used try (var is = jar.moduleDataProvider().open(file).get()) { diff --git a/src/test/resources/multirelease-noversions/META-INF/MANIFEST.MF b/src/test/resources/multirelease-noversions/META-INF/MANIFEST.MF new file mode 100644 index 00000000..e714012c --- /dev/null +++ b/src/test/resources/multirelease-noversions/META-INF/MANIFEST.MF @@ -0,0 +1 @@ +Multi-Release: true