mirror of https://github.com/apache/activemq.git
AMQ-6660 - Use a separate lock for lazy scheduler creation to prevent
deadlocks
Switch to using a dedicated lock to initialize the Scheduler object
inside of ActiveMQConnection to prevent a deadlock scenario that occurs
when using the intrinsic ActiveMQConnection lock. This is using double
checked locking so this lock will only be contended with during lazy
creation and then will rely on the volatile reference for future reads
and when stopping/closing.
(cherry picked from commit 3f5abd4433
)
This commit is contained in:
parent
51fa53977b
commit
dc786edecc
|
@ -200,6 +200,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
|||
protected AtomicInteger transportInterruptionProcessingComplete = new AtomicInteger(0);
|
||||
private long consumerFailoverRedeliveryWaitPeriod;
|
||||
private volatile Scheduler scheduler;
|
||||
private final Object schedulerLock = new Object();
|
||||
private boolean messagePrioritySupported = false;
|
||||
private boolean transactedIndividualAck = false;
|
||||
private boolean nonBlockingRedelivery = false;
|
||||
|
@ -2383,7 +2384,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
|||
// without lock contention report the closing state
|
||||
throw new ConnectionClosedException();
|
||||
}
|
||||
synchronized (this) {
|
||||
synchronized (schedulerLock) {
|
||||
result = scheduler;
|
||||
if (result == null) {
|
||||
checkClosed();
|
||||
|
|
Loading…
Reference in New Issue