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.
This commit is contained in:
parent
b94267c376
commit
3f5abd4433
|
@ -200,6 +200,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
||||||
protected AtomicInteger transportInterruptionProcessingComplete = new AtomicInteger(0);
|
protected AtomicInteger transportInterruptionProcessingComplete = new AtomicInteger(0);
|
||||||
private long consumerFailoverRedeliveryWaitPeriod;
|
private long consumerFailoverRedeliveryWaitPeriod;
|
||||||
private volatile Scheduler scheduler;
|
private volatile Scheduler scheduler;
|
||||||
|
private final Object schedulerLock = new Object();
|
||||||
private boolean messagePrioritySupported = false;
|
private boolean messagePrioritySupported = false;
|
||||||
private boolean transactedIndividualAck = false;
|
private boolean transactedIndividualAck = false;
|
||||||
private boolean nonBlockingRedelivery = false;
|
private boolean nonBlockingRedelivery = false;
|
||||||
|
@ -2383,7 +2384,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
||||||
// without lock contention report the closing state
|
// without lock contention report the closing state
|
||||||
throw new ConnectionClosedException();
|
throw new ConnectionClosedException();
|
||||||
}
|
}
|
||||||
synchronized (this) {
|
synchronized (schedulerLock) {
|
||||||
result = scheduler;
|
result = scheduler;
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
checkClosed();
|
checkClosed();
|
||||||
|
|
Loading…
Reference in New Issue