diff --git a/core/src/main/java/org/restheart/plugins/PluginsClassloader.java b/core/src/main/java/org/restheart/plugins/PluginsClassloader.java index 746a3508b..5de36688a 100644 --- a/core/src/main/java/org/restheart/plugins/PluginsClassloader.java +++ b/core/src/main/java/org/restheart/plugins/PluginsClassloader.java @@ -52,6 +52,10 @@ public static void init(URL[] jars) { } } + public static boolean isInitialized() { + return SINGLETON != null; + } + private final URLClassLoader pluginsClassLoader; private PluginsClassloader(URL[] jars) throws IOException { diff --git a/core/src/main/java/org/restheart/plugins/PluginsScanner.java b/core/src/main/java/org/restheart/plugins/PluginsScanner.java index 20c3d985b..b1f86a496 100644 --- a/core/src/main/java/org/restheart/plugins/PluginsScanner.java +++ b/core/src/main/java/org/restheart/plugins/PluginsScanner.java @@ -93,6 +93,9 @@ public class PluginsScanner { RuntimeClassGraph rtcg = null; if (NativeImageBuildTimeChecker.isBuildTime()) { + if (!PluginsClassloader.isInitialized()) { + PluginsClassloader.init(new URL[0]); + } classGraph = new ClassGraph().disableModuleScanning() // added for GraalVM .disableDirScanning() // added for GraalVM .disableNestedJarScanning() // added for GraalVM diff --git a/core/src/test/java/org/restheart/plugins/PluginsTest.java b/core/src/test/java/org/restheart/plugins/PluginsTest.java index 80e2a8cda..9cc6dd114 100644 --- a/core/src/test/java/org/restheart/plugins/PluginsTest.java +++ b/core/src/test/java/org/restheart/plugins/PluginsTest.java @@ -123,7 +123,9 @@ public void validProviders() { } private static MockedStatic mockPluginsScanner(List providerDescriptors) { - PluginsClassloader.init(new URL[0]); + if (!PluginsClassloader.isInitialized()) { + PluginsClassloader.init(new URL[0]); + } var scanner = mockStatic(PluginsScanner.class); scanner.when(PluginsScanner::providers).thenReturn(providerDescriptors); return scanner;