[hornetq-commits] JBoss hornetq SVN: r11603 - branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Oct 26 08:05:14 EDT 2011


Author: borges
Date: 2011-10-26 08:05:13 -0400 (Wed, 26 Oct 2011)
New Revision: 11603

Modified:
   branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
Log:
Avoid locking the locator inside close() as that can also cause dead-locks.

The "synchronized" in createFactory() should be revisited and probably deleted.

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-10-26 11:06:55 UTC (rev 11602)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java	2011-10-26 12:05:13 UTC (rev 11603)
@@ -599,7 +599,7 @@
       return afterConnectListener;
    }
 
-   public synchronized ClientSessionFactory createSessionFactory(final TransportConfiguration transportConfiguration) throws Exception
+   public ClientSessionFactory createSessionFactory(final TransportConfiguration transportConfiguration) throws Exception
    {
       assertOpen();
 
@@ -1222,30 +1222,30 @@
       {
          for (ClientSessionFactoryInternal csf : connectingFactories)
          {
-            csf.causeExit();
-            csf.close();
+           csf.close();
          }
          connectingFactories.clear();
       }
       
-      synchronized (this)
+      synchronized (factories)
       {
          Set<ClientSessionFactoryInternal> clonedFactory = new HashSet<ClientSessionFactoryInternal>(factories);
 
-      for (ClientSessionFactory factory : clonedFactory)
-      {
-         if (sendClose)
+         for (ClientSessionFactory factory : clonedFactory)
          {
-            factory.close();
+            if (sendClose)
+            {
+               factory.close();
+            }
+            else
+            {
+               factory.cleanup();
+            }
          }
-         else
-         {
-            factory.cleanup();
-         }
+
+         factories.clear();
       }
 
-      factories.clear();
-
       if (shutdownPool)
       {
          if (threadPool != null)
@@ -1282,8 +1282,8 @@
       }
       readOnly = false;
 
-         state = STATE.CLOSED;
-      }
+      state = STATE.CLOSED;
+ 
    }
 
    /** This is directly called when the connection to the node is gone,
@@ -1477,28 +1477,31 @@
       topology.removeClusterTopologyListener(listener);
    }
 
-   public synchronized void addFactory(ClientSessionFactoryInternal factory)
+   private synchronized void addFactory(ClientSessionFactoryInternal factory)
    {
       if (factory == null)
       {
          return;
       }
 
-      if (isClosed())
+      synchronized (factories)
       {
-         factory.close();
-         return;
-      }
+         if (isClosed())
+         {
+            factory.close();
+            return;
+         }
 
-      TransportConfiguration backup = null;
+         TransportConfiguration backup = null;
 
-      if (topology != null)
-      {
-         backup = topology.getBackupForConnector(factory.getConnectorConfiguration());
+         if (topology != null)
+         {
+            backup = topology.getBackupForConnector(factory.getConnectorConfiguration());
+         }
+
+         factory.setBackupConnector(factory.getConnectorConfiguration(), backup);
+         factories.add(factory);
       }
-
-      factory.setBackupConnector(factory.getConnectorConfiguration(), backup);
-      factories.add(factory);
    }
 
    class StaticConnector implements Serializable



More information about the hornetq-commits mailing list