activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r581683 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
Date Wed, 03 Oct 2007 18:50:04 GMT
Author: rajdavies
Date: Wed Oct  3 11:50:03 2007
New Revision: 581683

URL: http://svn.apache.org/viewvc?rev=581683&view=rev
Log:
fix memory leak in ActiveMQConnection - with asyncConnectionThread not being shutdown on a
close

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java?rev=581683&r1=581682&r2=581683&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
Wed Oct  3 11:50:03 2007
@@ -593,6 +593,10 @@
                     // then we may need to call
                     // factory.onConnectionClose(this);
                     sessionTaskRunner.shutdown();
+                    
+                    if (asyncConnectionThread != null){
+                    	asyncConnectionThread.shutdown();
+                    }
 
                     closed.set(true);
                     closing.set(false);
@@ -1652,20 +1656,23 @@
     }
 
     public void onException(final IOException error) {
-        onAsyncException(error);
-        asyncConnectionThread.execute(new Runnable() {
-            public void run() {
-                transportFailed(error);
-                ServiceSupport.dispose(ActiveMQConnection.this.transport);
-                brokerInfoReceived.countDown();
-
-                for (Iterator<TransportListener> iter = transportListeners.iterator();
iter.hasNext();) {
-                    TransportListener listener = iter.next();
-                    listener.onException(error);
-                }
-            }
-        });
-    }
+		onAsyncException(error);
+		if (!closing.get() && !closed.get()) {
+			asyncConnectionThread.execute(new Runnable() {
+				public void run() {
+					transportFailed(error);
+					ServiceSupport.dispose(ActiveMQConnection.this.transport);
+					brokerInfoReceived.countDown();
+
+					for (Iterator<TransportListener> iter = transportListeners
+							.iterator(); iter.hasNext();) {
+						TransportListener listener = iter.next();
+						listener.onException(error);
+					}
+				}
+			});
+		}
+	}
 
     public void transportInterupted() {
         for (Iterator<ActiveMQSession> i = this.sessions.iterator(); i.hasNext();)
{



Mime
View raw message