Commit 2a051c2c authored by Ralph Goers's avatar Ralph Goers
Browse files

LOG4J2-2266 - Use classloaders when loading properties

No related merge requests found
Showing with 12 additions and 2 deletions
+12 -2
......@@ -316,12 +316,22 @@ public final class PropertiesUtil {
private Environment(final PropertySource propertySource) {
sources.add(propertySource);
for (final PropertySource source : ServiceLoader.load(PropertySource.class)) {
sources.add(source);
for (ClassLoader classLoader : LoaderUtil.getClassLoaders()) {
try {
loadPropertySource(classLoader);
} catch (Throwable ex) {
LowLevelLogUtil.log("Unable to retrieve propertySource from ClassLoader " + classLoader + ", " + ex.getMessage());
}
}
reload();
}
private void loadPropertySource(ClassLoader classLoader) {
for (final PropertySource source : ServiceLoader.load(PropertySource.class, classLoader)) {
sources.add(source);
}
}
private synchronized void reload() {
literal.clear();
normalized.clear();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment