Author: tabish
Date: Mon Sep 20 21:04:17 2010
New Revision: 999121

URL: http://svn.apache.org/viewvc?rev=999121&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-316

Fix a case where the connection's config object could be leaked on a shutdown 
where the failover transport has its timeout option set and am exception is 
thrown to the connection when its RemoveInfo command or ShutdownInfo command is 
sent.

Also unset the exception listener eariler than it was before since we don't 
care about async errors once we enter the disconnect method.

Modified:
    
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp

Modified: 
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
URL: 
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp?rev=999121&r1=999120&r2=999121&view=diff
==============================================================================
--- 
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
 (original)
+++ 
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
 Mon Sep 20 21:04:17 2010
@@ -181,7 +181,12 @@ ActiveMQConnection::ActiveMQConnection( 
 
////////////////////////////////////////////////////////////////////////////////
 ActiveMQConnection::~ActiveMQConnection() throw() {
     try {
-        this->close();
+
+        try{
+            this->close();
+        } catch(...) {}
+
+        // This must happen even if exceptions occur in the Close attempt.
         delete this->config;
     }
     AMQ_CATCH_NOTHROW( ActiveMQException )
@@ -436,6 +441,9 @@ void ActiveMQConnection::disconnect( lon
 
     try{
 
+        // Clear the listener, we don't care about async errors at this point.
+        this->config->transport->setTransportListener( NULL );
+
         // Remove our ConnectionId from the Broker
         Pointer<RemoveInfo> command( 
this->config->connectionInfo->createRemoveCommand() );
         command->setLastDeliveredSequenceId( lastDeliveredSequenceId );
@@ -451,9 +459,6 @@ void ActiveMQConnection::disconnect( lon
 
         if( this->config->transport != NULL ){
 
-            // Clear the listener, we don't care about errors at this point.
-            this->config->transport->setTransportListener( NULL );
-
             try{
                 this->config->transport->close();
             }catch( exceptions::ActiveMQException& ex ){


Reply via email to