[hornetq-commits] JBoss hornetq SVN: r11592 - trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Oct 25 09:09:53 EDT 2011
Author: borges
Date: 2011-10-25 09:09:53 -0400 (Tue, 25 Oct 2011)
New Revision: 11592
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ServerLocatorImpl.java
Log:
Fix dead-lock between connecting factories and serverLocator.
ServerLocator will be locked by ClientSessionFactoryInternal's which are trying
to connect. So we must call causeExit() on these before trying to acquire the
lock on ServerLocator.close()
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ServerLocatorImpl.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-10-25 12:32:41 UTC (rev 11591)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-10-25 13:09:53 UTC (rev 11592)
@@ -70,6 +70,7 @@
private transient String identity;
private final Set<ClientSessionFactoryInternal> factories = new HashSet<ClientSessionFactoryInternal>();
+ private final Set<ClientSessionFactoryInternal> connectingFactories = new HashSet<ClientSessionFactoryInternal>();
private TransportConfiguration[] initialConnectors;
@@ -624,11 +625,10 @@
threadPool,
scheduledThreadPool,
interceptors);
-
- factory.connect(reconnectAttempts, failoverOnInitialConnection);
-
- addFactory(factory);
-
+ connectingFactories.add(factory);
+ factory.connect(reconnectAttempts, failoverOnInitialConnection);
+ connectingFactories.remove(factory);
+ addFactory(factory);
return factory;
}
}
@@ -689,11 +689,17 @@
threadPool,
scheduledThreadPool,
interceptors);
+ connectingFactories.add(factory);
factory.connect(initialConnectAttempts, failoverOnInitialConnection);
+ connectingFactories.remove(factory);
}
catch (HornetQException e)
{
- factory.close();
+ if (factory != null)
+ {
+ connectingFactories.remove(factory);
+ factory.close();
+ }
factory = null;
if (e.getCode() == HornetQException.NOT_CONNECTED)
{
@@ -743,7 +749,6 @@
throw new HornetQException(HornetQException.CONNECTION_TIMEDOUT,
"Timed out waiting to receive cluster topology. Group:" + discoveryGroup);
}
-
}
addFactory(factory);
@@ -1214,6 +1219,11 @@
staticConnector.disconnect();
}
+ for (ClientSessionFactoryInternal factory : connectingFactories)
+ {
+ factory.causeExit();
+ factory.close();
+ }
synchronized (this)
{
Set<ClientSessionFactoryInternal> clonedFactory = new HashSet<ClientSessionFactoryInternal>(factories);
@@ -1464,10 +1474,19 @@
public synchronized void addFactory(ClientSessionFactoryInternal factory)
{
- if (factory != null)
+ if (factory == null)
{
- TransportConfiguration backup = null;
+ return;
+ }
+ if (closed || closing)
+ {
+ factory.close();
+ return;
+ }
+
+ TransportConfiguration backup = null;
+
if (topology != null)
{
backup = topology.getBackupForConnector(factory.getConnectorConfiguration());
@@ -1475,7 +1494,7 @@
factory.setBackupConnector(factory.getConnectorConfiguration(), backup);
factories.add(factory);
- }
+
}
final class StaticConnector implements Serializable
More information about the hornetq-commits
mailing list