You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2014/12/05 16:26:18 UTC
[1/2] activemq-6 git commit: HORNETQ-1381 create new threads under
AccessControlContext of the creator of ActiveMQThreadFactory
Repository: activemq-6
Updated Branches:
refs/heads/master 28ca327b8 -> e419feb88
HORNETQ-1381 create new threads under AccessControlContext of the creator of ActiveMQThreadFactory
Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/ff9052b8
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/ff9052b8
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/ff9052b8
Branch: refs/heads/master
Commit: ff9052b83b9ae9e4982d089eb2147f78bce6526d
Parents: b61747d
Author: Ivo Studensky <is...@redhat.com>
Authored: Fri Dec 5 12:23:48 2014 +0100
Committer: Ivo Studensky <is...@redhat.com>
Committed: Fri Dec 5 12:23:48 2014 +0100
----------------------------------------------------------------------
.../activemq/utils/ActiveMQThreadFactory.java | 51 +++++++++++++++-----
1 file changed, 38 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/ff9052b8/activemq-commons/src/main/java/org/apache/activemq/utils/ActiveMQThreadFactory.java
----------------------------------------------------------------------
diff --git a/activemq-commons/src/main/java/org/apache/activemq/utils/ActiveMQThreadFactory.java b/activemq-commons/src/main/java/org/apache/activemq/utils/ActiveMQThreadFactory.java
index 5c76120..b857825 100644
--- a/activemq-commons/src/main/java/org/apache/activemq/utils/ActiveMQThreadFactory.java
+++ b/activemq-commons/src/main/java/org/apache/activemq/utils/ActiveMQThreadFactory.java
@@ -16,6 +16,7 @@
*/
package org.apache.activemq.utils;
+import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.ThreadFactory;
@@ -40,6 +41,8 @@ public final class ActiveMQThreadFactory implements ThreadFactory
private final ClassLoader tccl;
+ private final AccessControlContext acc;
+
public ActiveMQThreadFactory(final String groupName, final boolean daemon, final ClassLoader tccl)
{
group = new ThreadGroup(groupName + "-" + System.identityHashCode(this));
@@ -49,24 +52,46 @@ public final class ActiveMQThreadFactory implements ThreadFactory
this.tccl = tccl;
this.daemon = daemon;
+
+ this.acc = (System.getSecurityManager() == null) ? null : AccessController.getContext();
}
public Thread newThread(final Runnable command)
{
- // always create a thread in a privileged block.
- return AccessController.doPrivileged(new PrivilegedAction<Thread>()
+ // create a thread in a privileged block if running with Security Manager
+ if (acc != null && System.getSecurityManager() != null)
+ {
+ return AccessController.doPrivileged(new ThreadCreateAction(command), acc);
+ }
+ else
+ {
+ return createThread(command);
+ }
+ }
+
+ private final class ThreadCreateAction implements PrivilegedAction<Thread>
+ {
+ private final Runnable target;
+
+ private ThreadCreateAction(final Runnable target)
+ {
+ this.target = target;
+ }
+
+ public Thread run()
{
- @Override
- public Thread run()
- {
- final Thread t = new Thread(group, command, "Thread-" + threadCount.getAndIncrement() + " (" + group.getName() + ")");
- t.setDaemon(daemon);
- t.setPriority(threadPriority);
- t.setContextClassLoader(tccl);
-
- return t;
- }
- });
+ return createThread(target);
+ }
+ }
+
+ private Thread createThread(final Runnable command)
+ {
+ final Thread t = new Thread(group, command, "Thread-" + threadCount.getAndIncrement() + " (" + group.getName() + ")");
+ t.setDaemon(daemon);
+ t.setPriority(threadPriority);
+ t.setContextClassLoader(tccl);
+
+ return t;
}
}
[2/2] activemq-6 git commit: Merge #33 on porting HornetQ fix,
based on https://issues.apache.org/jira/browse/ACTIVEMQ6-53
Posted by cl...@apache.org.
Merge #33 on porting HornetQ fix, based on https://issues.apache.org/jira/browse/ACTIVEMQ6-53
Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/e419feb8
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/e419feb8
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/e419feb8
Branch: refs/heads/master
Commit: e419feb882b34cc3ae88950f9ba002ec1971344d
Parents: 28ca327 ff9052b
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Dec 5 10:25:15 2014 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri Dec 5 10:25:15 2014 -0500
----------------------------------------------------------------------
.../activemq/utils/ActiveMQThreadFactory.java | 51 +++++++++++++++-----
1 file changed, 38 insertions(+), 13 deletions(-)
----------------------------------------------------------------------