This is an automated email from the ASF dual-hosted git repository.
tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/artemis.git
The following commit(s) were added to refs/heads/main by this push:
new c6fe0f7493 ARTEMIS-5874 mitigate dead-lock in STOMP
c6fe0f7493 is described below
commit c6fe0f74938e0241254f0dda5b164bd5964a8efe
Author: Justin Bertram <[email protected]>
AuthorDate: Sat Jan 31 19:30:34 2026 -0600
ARTEMIS-5874 mitigate dead-lock in STOMP
---
.../core/protocol/stomp/StompConnection.java | 35 +++++++---------------
1 file changed, 11 insertions(+), 24 deletions(-)
diff --git
a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
index f353afef03..eacc3fc307 100644
---
a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
+++
b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
@@ -28,6 +28,7 @@ import java.util.StringTokenizer;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import
org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
@@ -81,12 +82,11 @@ public final class StompConnection extends
AbstractRemotingConnection {
//this means login is valid. (stomp connection ok)
private boolean valid;
- private boolean destroyed = false;
+ private static final AtomicIntegerFieldUpdater<StompConnection>
DESTROYED_UPDATER = AtomicIntegerFieldUpdater.newUpdater(StompConnection.class,
"destroyed");
+ private volatile int destroyed;
private final Acceptor acceptorUsed;
- private final Object failLock = new Object();
-
private final boolean enableMessageID;
private final int minLargeMessageSize;
@@ -224,15 +224,9 @@ public final class StompConnection extends
AbstractRemotingConnection {
@Override
public void destroy() {
- synchronized (failLock) {
- if (destroyed) {
- return;
- }
-
- destroyed = true;
+ if (DESTROYED_UPDATER.compareAndSet(this, 0, 1)) {
+ internalClose();
}
-
- internalClose();
}
public Acceptor getAcceptorUsed() {
@@ -255,24 +249,17 @@ public final class StompConnection extends
AbstractRemotingConnection {
@Override
public void fail(final ActiveMQException me) {
- synchronized (failLock) {
- if (destroyed) {
- return;
- }
-
+ if (DESTROYED_UPDATER.compareAndSet(this, 0, 1)) {
StompFrame frame =
frameHandler.createStompFrame(Stomp.Responses.ERROR);
frame.addHeader(Stomp.Headers.Error.MESSAGE, me.getMessage());
sendFrame(frame, null);
+
ActiveMQServerLogger.LOGGER.connectionFailureDetected(me.getMessage(),
me.getType());
- destroyed = true;
- }
-
- ActiveMQServerLogger.LOGGER.connectionFailureDetected(me.getMessage(),
me.getType());
+ // Then call the listeners
+ callFailureListeners(me);
- // Then call the listeners
- callFailureListeners(me);
-
- internalClose();
+ internalClose();
+ }
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]