[hornetq-commits] JBoss hornetq SVN: r7920 - trunk/src/main/org/hornetq/utils.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Aug 27 05:22:17 EDT 2009


Author: jmesnil
Date: 2009-08-27 05:22:16 -0400 (Thu, 27 Aug 2009)
New Revision: 7920

Modified:
   trunk/src/main/org/hornetq/utils/HornetQThreadFactory.java
Log:
attach the thread to a group only if there is no security manager

* when sandboxed, the code does not have the RuntimePermission modifyThreadGroup and it will
  fail to create new Thread attached to a group

Modified: trunk/src/main/org/hornetq/utils/HornetQThreadFactory.java
===================================================================
--- trunk/src/main/org/hornetq/utils/HornetQThreadFactory.java	2009-08-27 09:02:32 UTC (rev 7919)
+++ trunk/src/main/org/hornetq/utils/HornetQThreadFactory.java	2009-08-27 09:22:16 UTC (rev 7920)
@@ -48,10 +48,17 @@
 
    public Thread newThread(final Runnable command)
    {
-      Thread t = new Thread(group, command, "Thread-" + threadCount.getAndIncrement() +
-                                            " (group:" +
-                                            group.getName() +
-                                            ")");
+      Thread t = null;
+      // attach the thread to a group only if there is no security manager:
+      // when sandboxed, the code does not have the RuntimePermission modifyThreadGroup 
+      if (System.getSecurityManager() == null)
+      {
+         t = new Thread(group, command, "Thread-" + threadCount.getAndIncrement() +
+                        " (group:" + group.getName() + ")");
+      } else
+      {
+         t = new Thread(command, "Thread-" + threadCount.getAndIncrement());
+      }
 
       t.setDaemon(daemon);
       t.setPriority(threadPriority);



More information about the hornetq-commits mailing list