Skip to content

Commit 19ccf6d

Browse files
committed
Load FileSystemProviders with system cl
1 parent 1a42666 commit 19ccf6d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/main/java/io/quarkus/fs/util/FileSystemProviders.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,19 @@ public class FileSystemProviders {
99
public static final FileSystemProvider ZIP_PROVIDER;
1010
static {
1111
FileSystemProvider foundZipProvider = null;
12-
for (FileSystemProvider installedProvider : FileSystemProvider.installedProviders()) {
13-
if (installedProvider.getScheme().equals("jar")) {
14-
foundZipProvider = installedProvider;
15-
break;
12+
final ClassLoader ccl = Thread.currentThread().getContextClassLoader();
13+
try {
14+
// We are loading "installed" FS providers that are loaded from the system classloader anyway
15+
// To avoid potential ClassCastExceptions we are setting the context classloader to the system one
16+
Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
17+
for (FileSystemProvider installedProvider : FileSystemProvider.installedProviders()) {
18+
if (installedProvider.getScheme().equals("jar")) {
19+
foundZipProvider = installedProvider;
20+
break;
21+
}
1622
}
23+
} finally {
24+
Thread.currentThread().setContextClassLoader(ccl);
1725
}
1826
ZIP_PROVIDER = foundZipProvider;
1927
}

0 commit comments

Comments
 (0)