You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cs...@apache.org on 2021/06/25 15:39:33 UTC
[activemq] branch activemq-5.16.x updated: AMQ-6660 - Use a
separate lock for lazy scheduler creation to prevent deadlocks
This is an automated email from the ASF dual-hosted git repository.
cshannon pushed a commit to branch activemq-5.16.x
in repository https://gitbox.apache.org/repos/asf/activemq.git
The following commit(s) were added to refs/heads/activemq-5.16.x by this push:
new dc786ed AMQ-6660 - Use a separate lock for lazy scheduler creation to prevent deadlocks
dc786ed is described below
commit dc786edeccb55cc16facb73b48466b3ef55263fa
Author: Christopher L. Shannon (cshannon) <ch...@gmail.com>
AuthorDate: Fri Jun 25 10:54:36 2021 -0400
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 3f5abd4433d3dca911ac418d899346e7dd675b7b)
---
.../src/main/java/org/apache/activemq/ActiveMQConnection.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
index 6d8ce63..5d11fb6 100644
--- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
+++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
@@ -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();