Author: nmittler Date: Sat Dec 16 15:05:43 2006 New Revision: 487909 URL: http://svn.apache.org/viewvc?view=rev&rev=487909 Log: [AMQCPP-28] Updates to fix memory leaks in integration tests
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/durable/DurableTester.cpp incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/simple/SimpleTester.cpp incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/transactional/TransactionTester.cpp incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/various/SimpleRollbackTest.cpp Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp?view=diff&rev=487909&r1=487908&r2=487909 ============================================================================== --- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp (original) +++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp Sat Dec 16 15:05:43 2006 @@ -46,10 +46,11 @@ Command* StompCommandReader::readCommand(void) throw ( CommandIOException ) { + StompFrame* frame = NULL; try { // Create a new Frame for reading to. - StompFrame* frame = new StompFrame(); + frame = new StompFrame(); // Read the command header. readStompCommandHeader( *frame ); @@ -63,9 +64,26 @@ // Return the Command, caller must delete it. return marshaler.marshal( frame ); } - AMQ_CATCH_RETHROW( CommandIOException ) - AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, CommandIOException ) - AMQ_CATCHALL_THROW( CommandIOException ) + catch( CommandIOException& ex ){ + if( frame != NULL ){ + delete frame; + } + ex.setMark( __FILE__, __LINE__); + throw ex; + } + catch( ActiveMQException& ex ){ + if( frame != NULL ){ + delete frame; + } + ex.setMark( __FILE__, __LINE__ ); + throw CommandIOException(ex); + } + catch( ... ){ + if( frame != NULL ){ + delete frame; + } + throw CommandIOException(__FILE__, __LINE__, "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/durable/DurableTester.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/durable/DurableTester.cpp?view=diff&rev=487909&r1=487908&r2=487909 ============================================================================== --- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/durable/DurableTester.cpp (original) +++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/durable/DurableTester.cpp Sat Dec 16 15:05:43 2006 @@ -141,6 +141,7 @@ } delete producer; delete consumer; + delete topic; } AMQ_CATCH_RETHROW( ActiveMQException ) AMQ_CATCHALL_THROW( ActiveMQException ) Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/simple/SimpleTester.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/simple/SimpleTester.cpp?view=diff&rev=487909&r1=487908&r2=487909 ============================================================================== --- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/simple/SimpleTester.cpp (original) +++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/simple/SimpleTester.cpp Sat Dec 16 15:05:43 2006 @@ -125,6 +125,7 @@ } delete producer; delete consumer; + delete topic } AMQ_CATCH_RETHROW( ActiveMQException ) AMQ_CATCHALL_THROW( ActiveMQException ) Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/transactional/TransactionTester.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/transactional/TransactionTester.cpp?view=diff&rev=487909&r1=487908&r2=487909 ============================================================================== --- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/transactional/TransactionTester.cpp (original) +++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/transactional/TransactionTester.cpp Sat Dec 16 15:05:43 2006 @@ -143,6 +143,7 @@ } delete producer; delete consumer; + delete topic; } AMQ_CATCH_RETHROW( ActiveMQException ) AMQ_CATCHALL_THROW( ActiveMQException ) Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/various/SimpleRollbackTest.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/various/SimpleRollbackTest.cpp?view=diff&rev=487909&r1=487908&r2=487909 ============================================================================== --- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/various/SimpleRollbackTest.cpp (original) +++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/various/SimpleRollbackTest.cpp Sat Dec 16 15:05:43 2006 @@ -191,6 +191,7 @@ delete producer; delete consumer; + delete topic; } AMQ_CATCH_RETHROW( ActiveMQException ) AMQ_CATCHALL_THROW( ActiveMQException )