Skip to content

Commit

Permalink
Merge pull request #473 from jamezp/LOGMGR-350-3.0
Browse files Browse the repository at this point in the history
[LOGMGR-350] Avoid TCCL when configuring the log manager
  • Loading branch information
jamezp authored Apr 30, 2024
2 parents c40af61 + d77a9bc commit 321d657
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/jboss/logmanager/LogManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ private void doConfigure(InputStream inputStream) {
if (configurator == null) {
int best = Integer.MAX_VALUE;
ConfiguratorFactory factory = null;
final ServiceLoader<ConfiguratorFactory> serviceLoader = ServiceLoader.load(ConfiguratorFactory.class);
final ServiceLoader<ConfiguratorFactory> serviceLoader = ServiceLoader.load(ConfiguratorFactory.class,
LogManager.class.getClassLoader());
final Iterator<ConfiguratorFactory> iterator = serviceLoader.iterator();
List<Throwable> problems = null;
for (;;)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public void configure(final LogContext logContext, final InputStream inputStream
context.attachIfAbsent(ContextConfiguration.CONTEXT_CONFIGURATION_KEY, configurator);
} else {
// Next check the service loader
final Iterator<LogContextConfigurator> serviceLoader = ServiceLoader.load(LogContextConfigurator.class).iterator();
final Iterator<LogContextConfigurator> serviceLoader = ServiceLoader
.load(LogContextConfigurator.class, PropertyLogContextConfigurator.class.getClassLoader()).iterator();
if (serviceLoader.hasNext()) {
serviceLoader.next().configure(context, null);
} else {
Expand All @@ -95,20 +96,18 @@ public void configure(final LogContext logContext, final InputStream inputStream

private static InputStream findConfiguration() {
final String propLoc = System.getProperty("logging.configuration");
if (propLoc != null)
if (propLoc != null) {
try {
return new URL(propLoc).openStream();
} catch (IOException e) {
StandardOutputStreams.printError("Unable to read the logging configuration from '%s' (%s)%n", propLoc, e);
}
final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
if (tccl != null)
try {
final InputStream stream = tccl.getResourceAsStream("logging.properties");
if (stream != null)
return stream;
} catch (Exception ignore) {
}
return PropertyLogContextConfigurator.class.getResourceAsStream("logging.properties");
}
final ClassLoader cl = PropertyLogContextConfigurator.class.getClassLoader();
try {
return cl.getResourceAsStream("logging.properties");
} catch (Exception ignore) {
return null;
}
}
}

0 comments on commit 321d657

Please sign in to comment.