This is an automated email from the ASF dual-hosted git repository. clebertsuconic pushed a commit to branch 2.19.x in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit 0beea29a8ff50f5683de4059b5256830039319c1 Author: Ryan Yeats <[email protected]> AuthorDate: Thu Dec 9 14:43:36 2021 -0700 ARTEMIS-3596 Pass class loader to ServiceLoader.load to fix OSGi issues (cherry picked from commit e460bea4b84ef1ff673dc3fa731dfbc4033df2e6) --- .../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 5131612..15c788f 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 @@ -26,7 +26,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 {
