Skip to content

Commit 1fbd0d6

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

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ public class FileSystemProviders {
99
public static final FileSystemProvider ZIP_PROVIDER;
1010
static {
1111
FileSystemProvider foundZipProvider = null;
12+
final ClassLoader ccl = Thread.currentThread().getContextClassLoader();
13+
try {
14+
// We are loading "installed" FS providers that are loaded from 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+
}
22+
}
23+
} finally {
24+
Thread.currentThread().setContextClassLoader(ccl);
25+
}
1226
for (FileSystemProvider installedProvider : FileSystemProvider.installedProviders()) {
1327
if (installedProvider.getScheme().equals("jar")) {
1428
foundZipProvider = installedProvider;

0 commit comments

Comments
 (0)