Author: clebert.suconic(a)jboss.com
Date: 2011-12-22 06:22:01 -0500 (Thu, 22 Dec 2011)
New Revision: 11927
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
Log:
https://issues.jboss.org/browse/JBPAPP-7785 - changing factories protection as I saw a
test hanging
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-12-22
04:23:07 UTC (rev 11926)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-12-22
11:22:01 UTC (rev 11927)
@@ -1289,23 +1289,24 @@
connectingFactories.clear();
}
+ Set<ClientSessionFactoryInternal> clonedFactory;
synchronized (factories)
{
- Set<ClientSessionFactoryInternal> clonedFactory = new
HashSet<ClientSessionFactoryInternal>(factories);
+ clonedFactory = new HashSet<ClientSessionFactoryInternal>(factories);
- for (ClientSessionFactory factory : clonedFactory)
+ factories.clear();
+ }
+
+ for (ClientSessionFactory factory : clonedFactory)
+ {
+ if (sendClose)
{
- if (sendClose)
- {
- factory.close();
- }
- else
- {
- factory.cleanup();
- }
+ factory.close();
}
-
- factories.clear();
+ else
+ {
+ factory.cleanup();
+ }
}
if (shutdownPool)
@@ -1420,14 +1421,17 @@
if (actMember != null && actMember.getConnector().getA() != null &&
actMember.getConnector().getB() != null)
{
+ HashSet<ClientSessionFactory> clonedFactories = new
HashSet<ClientSessionFactory>();
synchronized (factories)
{
- for (ClientSessionFactory factory : factories)
- {
-
((ClientSessionFactoryInternal)factory).setBackupConnector(actMember.getConnector().getA(),
-
actMember.getConnector().getB());
- }
+ clonedFactories.addAll(factories);
}
+
+ for (ClientSessionFactory factory : clonedFactories)
+ {
+
((ClientSessionFactoryInternal)factory).setBackupConnector(actMember.getConnector().getA(),
+
actMember.getConnector().getB());
+ }
}
updateArraysAndPairs();
@@ -1571,22 +1575,23 @@
return;
}
- synchronized (factories)
+ if (isClosed())
{
- if (isClosed())
- {
- factory.close();
- return;
- }
+ factory.close();
+ return;
+ }
- TransportConfiguration backup = null;
+ TransportConfiguration backup = null;
- if (ha)
- {
- backup =
topology.getBackupForConnector(factory.getConnectorConfiguration());
- }
+ if (ha)
+ {
+ backup = topology.getBackupForConnector(factory.getConnectorConfiguration());
+ }
- factory.setBackupConnector(factory.getConnectorConfiguration(), backup);
+ factory.setBackupConnector(factory.getConnectorConfiguration(), backup);
+
+ synchronized (factories)
+ {
factories.add(factory);
}
}