From 43067dc4091118a08431c134df9953cc14524b4a Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 4 Nov 2024 16:52:16 -0500 Subject: [PATCH] try to handle case where JVM is too new and has dropped SecurityManager --- .../java/io/cryostat/agent/ConfigModule.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/cryostat/agent/ConfigModule.java b/src/main/java/io/cryostat/agent/ConfigModule.java index 12a9b4c7..752b5656 100644 --- a/src/main/java/io/cryostat/agent/ConfigModule.java +++ b/src/main/java/io/cryostat/agent/ConfigModule.java @@ -239,11 +239,22 @@ public static Config provideConfig() { fns.add(Pair.of("Simple", ConfigProvider::getConfig)); Function, Callable> clConfigLoader = cl -> - () -> - ConfigProvider.getConfig( + () -> { + ClassLoader loader; + try { + loader = AccessController.doPrivileged( (PrivilegedExceptionAction) - cl.call())); + () -> cl.call()); + } catch (Exception e) { + log.warn( + "ClassLoader AccessController failure - is this JVM too new" + + " to have the AccessController and SecurityManager?", + e); + loader = cl.call(); + } + return ConfigProvider.getConfig(loader); + }; fns.add( Pair.of( "ResourcesUtil ClassLoader",