ARTEMIS-3596 Pass class loader to ServiceLoader.load to fix OSGi issues

This commit is contained in:
Ryan Yeats 2021-12-09 14:43:36 -07:00 committed by clebertsuconic
parent ca1accc202
commit e460bea4b8
4 changed files with 4 additions and 4 deletions

View File

@ -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;
}

View File

@ -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()) {

View File

@ -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();
}

View File

@ -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 {