diff --git a/src/main/java/org/jboss/ejb/client/legacy/JBossEJBProperties.java b/src/main/java/org/jboss/ejb/client/legacy/JBossEJBProperties.java index b3fa8fc19..558e8ed57 100644 --- a/src/main/java/org/jboss/ejb/client/legacy/JBossEJBProperties.java +++ b/src/main/java/org/jboss/ejb/client/legacy/JBossEJBProperties.java @@ -120,32 +120,36 @@ public final class JBossEJBProperties implements Contextual static { final AtomicReference onceRef = new AtomicReference<>(); - CONTEXT_MANAGER.setGlobalDefaultSupplier(() -> { - JBossEJBProperties value = onceRef.get(); - if (value == null) { - synchronized (onceRef) { - value = onceRef.get(); - if (value == null) { - try { - if (CONFIGURED_PATH_NAME != null) try { - File propertiesFile = new File(CONFIGURED_PATH_NAME); - if (! propertiesFile.isAbsolute()) { - propertiesFile = new File(SecurityUtils.getString(SystemProperties.USER_DIR), propertiesFile.toString()); + doPrivileged((PrivilegedAction) () -> { + CONTEXT_MANAGER.setGlobalDefaultSupplier(() -> { + JBossEJBProperties value = onceRef.get(); + if (value == null) { + synchronized (onceRef) { + value = onceRef.get(); + if (value == null) { + try { + if (CONFIGURED_PATH_NAME != null) try { + File propertiesFile = new File(CONFIGURED_PATH_NAME); + if (!propertiesFile.isAbsolute()) { + propertiesFile = new File(SecurityUtils.getString(SystemProperties.USER_DIR), propertiesFile.toString()); + } + value = JBossEJBProperties.fromFile(propertiesFile); + } catch (IOException e) { + Logs.MAIN.failedToFindEjbClientConfigFileSpecifiedBySysProp(SystemProperties.PROPERTIES_FILE_PATH, e); + value = JBossEJBProperties.fromClassPath(); + } + else { + value = JBossEJBProperties.fromClassPath(); } - value = JBossEJBProperties.fromFile(propertiesFile); } catch (IOException e) { - Logs.MAIN.failedToFindEjbClientConfigFileSpecifiedBySysProp(SystemProperties.PROPERTIES_FILE_PATH, e); - value = JBossEJBProperties.fromClassPath(); - } else { - value = JBossEJBProperties.fromClassPath(); } - } catch (IOException e) { + onceRef.set(value); } - onceRef.set(value); } } - } - return value; + return value; + }); + return null; // PrivilegedAction requires a return value }); }