[hornetq-commits] JBoss hornetq SVN: r12132 - trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Feb 17 05:27:16 EST 2012


Author: borges
Date: 2012-02-17 05:27:16 -0500 (Fri, 17 Feb 2012)
New Revision: 12132

Modified:
   trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
Log:
Guard getConnection() (public API!) from concurrent access.

Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java	2012-02-17 10:26:56 UTC (rev 12131)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java	2012-02-17 10:27:16 UTC (rev 12132)
@@ -114,11 +114,12 @@
 
    private final Object exitLock = new Object();
 
-   private final Object createSessionLock = new Object();
 
    private boolean inCreateSession;
 
+   private final Object createSessionLock = new Object();
    private final Object failoverLock = new Object();
+   private final Object connectionLock = new Object();
 
    private final ExecutorFactory orderedExecutorFactory;
 
@@ -1114,6 +1115,10 @@
 
    public CoreRemotingConnection getConnection()
    {
+      if (closed)
+         throw new IllegalStateException("ClientSessionFactory is closed!");
+      synchronized (connectionLock)
+      {
       if (connection == null)
       {
          Connection tc = null;
@@ -1329,6 +1334,7 @@
       }
 
       return connection;
+      }
    }
 
    public void sendNodeAnnounce(final long currentEventID,
@@ -1680,9 +1686,6 @@
       }
    }
 
-   /* (non-Javadoc)
-    * @see java.lang.Object#toString()
-    */
    @Override
    public String toString()
    {



More information about the hornetq-commits mailing list