From 922f12a8bedbc1ca80241d9980df954a02dd9627 Mon Sep 17 00:00:00 2001 From: Emmanuel Hugonnet Date: Mon, 13 Nov 2023 13:54:18 +0100 Subject: [PATCH] ARTEMIS-4499 fix ThreadCreateAction so it works properly with SecurityManager Issue: https://issues.apache.org/jira/browse/ARTEMIS-4499 Signed-off-by: Emmanuel Hugonnet --- .../activemq/artemis/utils/ActiveMQThreadFactory.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 b8f8e809414..b9c3c28342a 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 void run() { }; 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; }