ARTEMIS-4499 fix ThreadCreateAction so it works properly with SecurityManager

Issue: https://issues.apache.org/jira/browse/ARTEMIS-4499

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
This commit is contained in:
Emmanuel Hugonnet 2023-11-13 13:54:18 +01:00 committed by clebertsuconic
parent 4838cb7725
commit 4a13449056
1 changed files with 8 additions and 1 deletions

View File

@ -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<Void>) () -> {
t.setContextClassLoader(tccl);
return null; // nothing to return
});
} else {
t.setContextClassLoader(tccl);
}
return t;
}