You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2009/03/17 16:14:18 UTC

svn commit: r755274 - in /activemq/activemq-cpp/trunk/src/main: activemq/transport/failover/FailoverTransport.cpp decaf/lang/Pointer.h

Author: tabish
Date: Tue Mar 17 15:14:18 2009
New Revision: 755274

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

Fix a bug in the Pointer class that was causing a leak from the failure of a dynamic cast.  Fix the isShutdownCommand method to use the Command class' isRemoveInfo instead of a dynamic cast attempt to improve performance.

Modified:
    activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.cpp
    activemq/activemq-cpp/trunk/src/main/decaf/lang/Pointer.h

Modified: activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.cpp?rev=755274&r1=755273&r2=755274&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.cpp Tue Mar 17 15:14:18 2009
@@ -82,15 +82,9 @@
 
     if( command != NULL ) {
 
-        if( command->isShutdownInfo() ) {
+        if( command->isShutdownInfo() || command->isRemoveInfo() ) {
             return true;
         }
-
-        try{
-            Pointer<RemoveInfo> remove = command.dynamicCast<RemoveInfo>();
-
-            return true;
-        } AMQ_CATCHALL_NOTHROW()
     }
 
     return false;
@@ -386,6 +380,7 @@
         }
 
         backups.clear();
+        requestMap.clear();
 
         if( connectedTransport != NULL ) {
             transportToStop = connectedTransport;

Modified: activemq/activemq-cpp/trunk/src/main/decaf/lang/Pointer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Pointer.h?rev=755274&r1=755273&r2=755274&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Pointer.h (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Pointer.h Tue Mar 17 15:14:18 2009
@@ -142,7 +142,7 @@
          */
         template< typename T1, typename R1 >
         Pointer( const Pointer<T1, R1>& value, const STATIC_CAST_TOKEN& ) throw() :
-            REFCOUNTER( value ), value( dynamic_cast<T*>( value.get() ) ) {
+            REFCOUNTER( value ), value( static_cast<T*>( value.get() ) ) {
         }
 
         /**
@@ -160,6 +160,9 @@
                 REFCOUNTER( value ), value( dynamic_cast<T*>( value.get() ) ) {
 
             if( this->value == NULL ) {
+                // Remove the reference we took in the Reference Counter's ctor since we
+                // didn't actually create one as the dynamic cast failed..
+                this->release();
                 throw decaf::lang::exceptions::ClassCastException(
                     __FILE__, __LINE__, "Failed to cast source pointer to this type." );
             }