diff --git a/classloader/src/main/java/io/smallrye/common/classloader/ClassPathUtils.java b/classloader/src/main/java/io/smallrye/common/classloader/ClassPathUtils.java index 386d6a5..eae13b9 100644 --- a/classloader/src/main/java/io/smallrye/common/classloader/ClassPathUtils.java +++ b/classloader/src/main/java/io/smallrye/common/classloader/ClassPathUtils.java @@ -14,6 +14,7 @@ import java.nio.file.spi.FileSystemProvider; import java.util.Enumeration; import java.util.Map; +import java.util.NoSuchElementException; import java.util.function.Consumer; import java.util.function.Function; @@ -109,10 +110,19 @@ public static void consumeAsPath(URL url, Consumer consumer) { static { final ClassLoader ccl = Thread.currentThread().getContextClassLoader(); + FileSystemProvider provider = null; try { Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader()); - JAR_PROVIDER = FileSystemProvider.installedProviders().stream().filter(p -> p.getScheme().equals("jar")).findFirst() - .orElseThrow(); + for (FileSystemProvider p : FileSystemProvider.installedProviders()) { + if (p.getScheme().equals("jar")) { + provider = p; + break; + } + } + if (provider == null) { + throw new NoSuchElementException("Unable to find provider supporting jar scheme"); + } + JAR_PROVIDER = provider; } finally { Thread.currentThread().setContextClassLoader(ccl); }