Skip to content

Commit

Permalink
Remove the explicit dependency on org.jboss.logmanager and add an exp…
Browse files Browse the repository at this point in the history
…licit opens to the module if it exists.

Signed-off-by: James R. Perkins <jperkins@redhat.com>
  • Loading branch information
jamezp committed Jun 28, 2023
1 parent 1353007 commit 1ae7725
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/main/java/module-info.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: org.jboss.logging

requires:
- module: org.jboss.logmanager
static: true
- module: org.slf4j
static: true
- module: log4j.api # log4j 1, theoretically
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/jboss/logging/LoggerProviders.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,17 @@ private static LoggerProvider tryLog4j(final ClassLoader cl, final String via) t

private static LoggerProvider tryJBossLogManager(final ClassLoader cl, final String via) throws ClassNotFoundException {
final Class<? extends LogManager> logManagerClass = LogManager.getLogManager().getClass();
if (logManagerClass == Class.forName("org.jboss.logmanager.LogManager", false, cl)
final Class<?> jblLogManager = Class.forName("org.jboss.logmanager.LogManager", false,
Logger.class.getClassLoader());
if (logManagerClass == jblLogManager
&& Class.forName("org.jboss.logmanager.Logger$AttachmentKey", true, cl).getClassLoader() == logManagerClass
.getClassLoader()) {
// We do not have an explicit dependency on org.jboss.logmanager as we could end up with cyclic dependencies.
// Therefore, we check the modules are named, and if they are we add an explicit reads.
final Module module = LoggerProviders.class.getModule();
if (module.isNamed() && jblLogManager.getModule().isNamed()) {
module.addReads(jblLogManager.getModule());
}
final LoggerProvider provider = new JBossLogManagerProvider();
logProvider(provider, via);
return provider;
Expand Down

0 comments on commit 1ae7725

Please sign in to comment.