diff --git a/src/main/java/io/cryostat/agent/ConfigModule.java b/src/main/java/io/cryostat/agent/ConfigModule.java index e5036c14..6f6ea8c9 100644 --- a/src/main/java/io/cryostat/agent/ConfigModule.java +++ b/src/main/java/io/cryostat/agent/ConfigModule.java @@ -222,30 +222,32 @@ public static Config provideConfig() { fns.add( Pair.of( "ResourcesUtil Classloader", - () -> { - // if we don't do this then the SmallRye Config loader may end up with a - // null classloader in the case that the Agent starts separately and is - // dynamically attached to a running VM, which results in an NPE. Here - // we try to detect and preempt that case and ensure that there is a - // reasonable classloader for the SmallRye config loader to use. - PrivilegedExceptionAction pea = - ResourcesUtil::getClassLoader; - return ConfigProvider.getConfig(AccessController.doPrivileged(pea)); - })); + () -> + ConfigProvider.getConfig( + AccessController.doPrivileged( + (PrivilegedExceptionAction) + ResourcesUtil::getClassLoader)))); fns.add( Pair.of( - "Agent JAR URL Classloader", - () -> { - PrivilegedExceptionAction pea = - () -> - new URLClassLoader( - new URL[] {Agent.selfJarLocation().toURL()}); - return ConfigProvider.getConfig(AccessController.doPrivileged(pea)); - })); + "Config Class Classloader", + () -> + ConfigProvider.getConfig( + AccessController.doPrivileged( + (PrivilegedExceptionAction) + Config.class::getClassLoader)))); fns.add( Pair.of( - "Config Class Classloader", - () -> ConfigProvider.getConfig(Config.class.getClassLoader()))); + "Agent JAR URL Classloader", + () -> + ConfigProvider.getConfig( + AccessController.doPrivileged( + (PrivilegedExceptionAction) + () -> + new URLClassLoader( + new URL[] { + Agent.selfJarLocation() + .toURL() + }))))); Config config = null; for (Pair> fn : fns) {