Skip to content

Commit 16d4b74

Browse files
Only modify threads if allowed to by the environment
1 parent 374ec9d commit 16d4b74

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/com/rabbitmq/client/impl/ChannelManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
}

0 commit comments

Comments
 (0)