You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2021/12/14 18:21:16 UTC

[activemq-artemis] branch main updated: ARTEMIS-3596 Pass class loader to ServiceLoader.load to fix OSGi issues

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new e460bea  ARTEMIS-3596 Pass class loader to ServiceLoader.load to fix OSGi issues
e460bea is described below

commit e460bea4b84ef1ff673dc3fa731dfbc4033df2e6
Author: Ryan Yeats <ry...@connexta.com>
AuthorDate: Thu Dec 9 14:43:36 2021 -0700

    ARTEMIS-3596 Pass class loader to ServiceLoader.load to fix OSGi issues
---
 .../artemis/spi/core/remoting/ssl/OpenSSLContextFactoryProvider.java    | 2 +-
 .../artemis/spi/core/remoting/ssl/SSLContextFactoryProvider.java        | 2 +-
 .../java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java | 2 +-
 .../java/org/apache/activemq/artemis/ra/recovery/RecoveryManager.java   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ssl/OpenSSLContextFactoryProvider.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ssl/OpenSSLContextFactoryProvider.java
index b50d7f3..b34ec97 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ssl/OpenSSLContextFactoryProvider.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ssl/OpenSSLContextFactoryProvider.java
@@ -25,7 +25,7 @@ public class OpenSSLContextFactoryProvider {
    private static final OpenSSLContextFactory FACTORY;
    static {
       OpenSSLContextFactory factoryWithHighestPrio = null;
-      for (OpenSSLContextFactory factory : ServiceLoader.load(OpenSSLContextFactory.class)) {
+      for (OpenSSLContextFactory factory : ServiceLoader.load(OpenSSLContextFactory.class, OpenSSLContextFactoryProvider.class.getClassLoader())) {
          if (factoryWithHighestPrio == null || factory.getPriority() > factoryWithHighestPrio.getPriority()) {
             factoryWithHighestPrio = factory;
          }
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ssl/SSLContextFactoryProvider.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ssl/SSLContextFactoryProvider.java
index 9ccceab..185e037 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ssl/SSLContextFactoryProvider.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ssl/SSLContextFactoryProvider.java
@@ -29,7 +29,7 @@ import javax.net.ssl.SSLContext;
 public class SSLContextFactoryProvider {
    private static final SSLContextFactory factory;
    static {
-      ServiceLoader<SSLContextFactory> loader = ServiceLoader.load(SSLContextFactory.class, Thread.currentThread().getContextClassLoader());
+      ServiceLoader<SSLContextFactory> loader = ServiceLoader.load(SSLContextFactory.class, SSLContextFactoryProvider.class.getClassLoader());
       final List<SSLContextFactory> factories = new ArrayList<>();
       loader.forEach(factories::add);
       if (factories.isEmpty()) {
diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java
index f35d41f..64cdd52 100644
--- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java
+++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java
@@ -2050,7 +2050,7 @@ public final class JMSBridgeImpl implements JMSBridge {
       if (registry == null) {
          for (String locatorClasse : RESOURCE_RECOVERY_CLASS_NAMES) {
             try {
-               ServiceLoader<ActiveMQRegistry> sl = ServiceLoader.load(ActiveMQRegistry.class);
+               ServiceLoader<ActiveMQRegistry> sl = ServiceLoader.load(ActiveMQRegistry.class, JMSBridgeImpl.class.getClassLoader());
                if (sl.iterator().hasNext()) {
                   registry = sl.iterator().next();
                }
diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/recovery/RecoveryManager.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/recovery/RecoveryManager.java
index 0abde97..208b5e2 100644
--- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/recovery/RecoveryManager.java
+++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/recovery/RecoveryManager.java
@@ -79,7 +79,7 @@ public final class RecoveryManager {
 
       for (String locatorClasse : locatorClasses) {
          try {
-            ServiceLoader<ActiveMQRegistry> sl = ServiceLoader.load(ActiveMQRegistry.class);
+            ServiceLoader<ActiveMQRegistry> sl = ServiceLoader.load(ActiveMQRegistry.class, RecoveryManager.class.getClassLoader());
             if (sl.iterator().hasNext()) {
                registry = sl.iterator().next();
             } else {