[hornetq-commits] JBoss hornetq SVN: r11741 - branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Nov 22 14:31:59 EST 2011


Author: clebert.suconic at jboss.com
Date: 2011-11-22 14:31:59 -0500 (Tue, 22 Nov 2011)
New Revision: 11741

Modified:
   branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompConnection.java
   branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java
Log:
avoiding dead locks through stomp / close session

Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompConnection.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompConnection.java	2011-11-22 17:23:39 UTC (rev 11740)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompConnection.java	2011-11-22 19:31:59 UTC (rev 11741)
@@ -17,6 +17,7 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.Executor;
 
 import org.hornetq.api.core.HornetQBuffer;
 import org.hornetq.api.core.HornetQBuffers;
@@ -66,6 +67,8 @@
 
    private final Object failLock = new Object();
    
+   private final Executor executor;
+   
    private volatile boolean dataReceived;
 
    public StompDecoder getDecoder()
@@ -73,7 +76,7 @@
       return decoder;
    }
 
-   StompConnection(final Acceptor acceptorUsed, final Connection transportConnection, final StompProtocolManager manager)
+   StompConnection(final Acceptor acceptorUsed, final Connection transportConnection, final StompProtocolManager manager, final Executor executor)
    {
       this.transportConnection = transportConnection;
 
@@ -82,6 +85,8 @@
       this.creationTime = System.currentTimeMillis();
       
       this.acceptorUsed = acceptorUsed;
+      
+      this.executor = executor;
    }
 
    public void addFailureListener(final FailureListener listener)
@@ -322,7 +327,6 @@
    private void callFailureListeners(final HornetQException me)
    {
       final List<FailureListener> listenersClone = new ArrayList<FailureListener>(failureListeners);
-
       for (final FailureListener listener : listenersClone)
       {
          try
@@ -343,20 +347,26 @@
    {
       final List<CloseListener> listenersClone = new ArrayList<CloseListener>(closeListeners);
 
-      for (final CloseListener listener : listenersClone)
-      {
-         try
+      // avoiding a dead lock
+      executor.execute(new Runnable(){
+         public void run()
          {
-            listener.connectionClosed();
+            for (final CloseListener listener : listenersClone)
+            {
+               try
+               {
+                  listener.connectionClosed();
+               }
+               catch (final Throwable t)
+               {
+                  // Failure of one listener to execute shouldn't prevent others
+                  // from
+                  // executing
+                  log.error("Failed to execute failure listener", t);
+               }
+            }
          }
-         catch (final Throwable t)
-         {
-            // Failure of one listener to execute shouldn't prevent others
-            // from
-            // executing
-            log.error("Failed to execute failure listener", t);
-         }
-      }
+      });
    }
 
 }

Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java	2011-11-22 17:23:39 UTC (rev 11740)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java	2011-11-22 19:31:59 UTC (rev 11741)
@@ -120,7 +120,7 @@
 
    public ConnectionEntry createConnectionEntry(final Acceptor acceptorUsed, final Connection connection)
    {
-      StompConnection conn = new StompConnection(acceptorUsed, connection, this);
+      StompConnection conn = new StompConnection(acceptorUsed, connection, this, server.getExecutorFactory().getExecutor());
 
       // Note that STOMP has no heartbeat, so if connection ttl is non zero, data must continue to be sent or connection
       // will be timed out and closed!



More information about the hornetq-commits mailing list