Skip to content

Commit

Permalink
Merge pull request #109 from Sanne/acc
Browse files Browse the repository at this point in the history
Set AccessControlContext to null on termination to release captured c…
  • Loading branch information
stuartwdouglas committed Aug 10, 2021
2 parents 322e03d + b3cb132 commit c16d740
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/main/java/org/jboss/threads/EnhancedQueueExecutor.java
Expand Up @@ -191,7 +191,7 @@ public final class EnhancedQueueExecutor extends EnhancedQueueExecutorBase6 impl
* The access control context of the creating thread.
* Will be set to null when the MBean is not registered.
*/
private final AccessControlContext acc;
private volatile AccessControlContext acc;
/**
* The context handler for the user-defined context.
*/
Expand Down Expand Up @@ -1861,11 +1861,16 @@ void completeTermination() {
waiters = waiters.getNext();
}
tail.setNext(TERMINATE_COMPLETE);
if (this.acc != null) {
final Object handle = this.handle;
if (handle != null) {
intr = intr || Thread.interrupted();
doPrivileged(new MBeanUnregisterAction(handle), acc);
if (!DISABLE_MBEAN) {
//The check for DISABLE_MBEAN is redundant as acc would be null,
//but GraalVM needs the hint so to not make JMX reachable.
if (this.acc != null) {
final Object handle = this.handle;
if (handle != null) {
intr = intr || Thread.interrupted();
doPrivileged(new MBeanUnregisterAction(handle), acc);
}
this.acc = null;
}
}
} finally {
Expand Down

0 comments on commit c16d740

Please sign in to comment.