From 220e39ef1fa0173f2da9772c5e4911681bbd056f Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Thu, 3 Sep 2015 09:29:15 -0400 Subject: [PATCH] ARTEMIS-217 fixing dead lock https://issues.apache.org/jira/browse/ARTEMIS-217 fixing dead lock This is using a separate lock for notifications, this way we won't hold a lock while communicating on netty which was the issue here. --- .../artemis/core/client/impl/ServerLocatorImpl.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java index deb17dad82..bed47b7a21 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java @@ -816,7 +816,9 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery } } } while (retry); + } + synchronized (topologyArrayGuard) { // We always wait for the topology, as the server // will send a single element if not cluster // so clients can know the id of the server they are connected to @@ -824,7 +826,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery while (!isClosed() && !receivedTopology && timeout > System.currentTimeMillis()) { // Now wait for the topology try { - wait(1000); + topologyArrayGuard.wait(1000); } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); @@ -847,7 +849,6 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery return factory; } - } public boolean isHA() { @@ -1410,10 +1411,10 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery updateArraysAndPairs(); if (last) { - synchronized (this) { + synchronized (topologyArrayGuard) { receivedTopology = true; // Notify if waiting on getting topology - notifyAll(); + topologyArrayGuard.notifyAll(); } } }