File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
src/com/rabbitmq/client/impl Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,9 @@ public void run() {
116116 }
117117 };
118118 Thread shutdownThread = threadFactory .newThread (target , "ConsumerWorkService shutdown monitor" );
119- shutdownThread .setDaemon (true );
119+ if (Environment .isAllowedToModifyThreads ()) {
120+ shutdownThread .setDaemon (true );
121+ }
120122 shutdownThread .start ();
121123 }
122124
Original file line number Diff line number Diff line change 1+ package com .rabbitmq .client .impl ;
2+
3+ /**
4+ * Infers information about the execution environment, e.g.
5+ * security permissions.
6+ */
7+ class Environment {
8+ public static boolean isAllowedToModifyThreads () {
9+ SecurityManager sm = new SecurityManager ();
10+ try {
11+ sm .checkPermission (new RuntimePermission ("modifyThread" ));
12+ sm .checkPermission (new RuntimePermission ("modifyThreadGroup" ));
13+ return true ;
14+ } catch (SecurityException se ) {
15+ return false ;
16+ }
17+ }
18+ }
You can’t perform that action at this time.
0 commit comments