Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LOGMGR-350] Avoid TCCL when configuring the log manager #469

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -117,7 +117,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;
}
}
}