diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java index b8f8e80941..b9c3c28342 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java @@ -123,7 +123,14 @@ public final class ActiveMQThreadFactory implements ThreadFactory { }; t.setDaemon(daemon); t.setPriority(threadPriority); - t.setContextClassLoader(tccl); + if (acc != null) { + AccessController.doPrivileged((PrivilegedAction) () -> { + t.setContextClassLoader(tccl); + return null; // nothing to return + }); + } else { + t.setContextClassLoader(tccl); + } return t; }