Skip to content

Commit

Permalink
Merge pull request #108 from Sanne/acc
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd authored Jul 30, 2021
2 parents 13a8631 + aa18dda commit 322e03d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/org/jboss/threads/EnhancedQueueExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public final class EnhancedQueueExecutor extends EnhancedQueueExecutorBase6 impl
private final Object handle;
/**
* The access control context of the creating thread.
* Will be set to null when the MBean is not registered.
*/
private final AccessControlContext acc;
/**
Expand Down Expand Up @@ -344,7 +345,6 @@ public final class EnhancedQueueExecutor extends EnhancedQueueExecutorBase6 impl

EnhancedQueueExecutor(final Builder builder) {
super();
this.acc = getContext();
int maxSize = builder.getMaximumPoolSize();
int coreSize = min(builder.getCorePoolSize(), maxSize);
this.handoffExecutor = builder.getHandoffExecutor();
Expand All @@ -361,11 +361,13 @@ public final class EnhancedQueueExecutor extends EnhancedQueueExecutorBase6 impl
queueSize = withMaxQueueSize(withCurrentQueueSize(0L, 0), builder.getMaximumQueueSize());
mxBean = new MXBeanImpl();
if (! DISABLE_MBEAN && builder.isRegisterMBean()) {
this.acc = getContext();
final String configuredName = builder.getMBeanName();
final String finalName = configuredName != null ? configuredName : "threadpool-" + sequence.getAndIncrement();
handle = doPrivileged(new MBeanRegisterAction(finalName, mxBean), acc);
} else {
handle = null;
this.acc = null;
}
}

Expand Down Expand Up @@ -1859,7 +1861,7 @@ void completeTermination() {
waiters = waiters.getNext();
}
tail.setNext(TERMINATE_COMPLETE);
if (! DISABLE_MBEAN) {
if (this.acc != null) {
final Object handle = this.handle;
if (handle != null) {
intr = intr || Thread.interrupted();
Expand Down

0 comments on commit 322e03d

Please sign in to comment.