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 2008/11/20 15:27:15 UTC

svn commit: r719236 - in /activemq/activemq-cpp/tags/activemq-cpp-2.2.2: ./ src/examples/ src/main/activemq/connector/openwire/commands/ src/main/activemq/core/ src/main/activemq/transport/ src/test/activemq/core/

Author: tabish
Date: Thu Nov 20 06:27:14 2008
New Revision: 719236

URL: http://svn.apache.org/viewvc?rev=719236&view=rev
Log:
Updates for the new Release.  Set version number and release artifact Id.

Added:
    activemq/activemq-cpp/tags/activemq-cpp-2.2.2/Makefile.win
      - copied unchanged from r719232, activemq/activemq-cpp/trunk/Makefile.win
Modified:
    activemq/activemq-cpp/tags/activemq-cpp-2.2.2/   (props changed)
    activemq/activemq-cpp/tags/activemq-cpp-2.2.2/README.txt
    activemq/activemq-cpp/tags/activemq-cpp-2.2.2/configure.ac
    activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/examples/main.cpp
    activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/connector/openwire/commands/Message.cpp
    activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/core/ActiveMQConnectionFactory.cpp
    activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/transport/MockTransport.cpp
    activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/transport/MockTransport.h
    activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp
    activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/test/activemq/core/ActiveMQConnectionFactoryTest.h

Propchange: activemq/activemq-cpp/tags/activemq-cpp-2.2.2/
------------------------------------------------------------------------------
    svn:mergeinfo = /activemq/activemq-cpp/trunk:718699-719232

Modified: activemq/activemq-cpp/tags/activemq-cpp-2.2.2/README.txt
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/tags/activemq-cpp-2.2.2/README.txt?rev=719236&r1=719235&r2=719236&view=diff
==============================================================================
--- activemq/activemq-cpp/tags/activemq-cpp-2.2.2/README.txt (original)
+++ activemq/activemq-cpp/tags/activemq-cpp-2.2.2/README.txt Thu Nov 20 06:27:14 2008
@@ -193,6 +193,11 @@
 There are a couple or things that you will need to setup to ensure that
 the MSVC compile succeeds.
 
+* When linking your application to the DLL version of the ActiveMQ-CPP library
+  you must link your app the the same runtime version that the DLL is linked to,
+  otherwise your application will cause heap corruption when you delete objects
+  that are created in the ActiveMQ-CPP DLL's heap.
+
 * You need to download and install the Platform SDK if you don't have it
   installed already.  On machines where you intend to use the built libraries
   and executable you will also need to install the MS Redistributable for the
@@ -201,6 +206,7 @@
 * Ensure that the path to you MSVC install is set in the PATH env variable.
   You can test this by typing cl.exe at the command line, if you get an
   error complaining that its not found, then you'll need to fix your PATH.
+
 * Set the INCLUDE env variable to include the path to your MSVC includes,
   and the platform SDK includes. For example:
 

Modified: activemq/activemq-cpp/tags/activemq-cpp-2.2.2/configure.ac
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/tags/activemq-cpp-2.2.2/configure.ac?rev=719236&r1=719235&r2=719236&view=diff
==============================================================================
--- activemq/activemq-cpp/tags/activemq-cpp-2.2.2/configure.ac (original)
+++ activemq/activemq-cpp/tags/activemq-cpp-2.2.2/configure.ac Thu Nov 20 06:27:14 2008
@@ -15,6 +15,8 @@
 # limitations under the License.
 # ---------------------------------------------------------------------------
 
+AC_PREREQ(2.61)
+
 ## --------------------------------
 ## Initialization macros.
 ## --------------------------------
@@ -26,7 +28,7 @@
 ## Define the Version variables
 ## -----------------------------------------------
 ACTIVEMQ_LIBRARY_NAME=activemq-cpp
-ACTIVEMQ_VERSION=2.3-SNAPSHOT
+ACTIVEMQ_VERSION=2.2.2
 ACTIVEMQ_API_VERSION=${ACTIVEMQ_VERSION}
 
 ##
@@ -42,7 +44,7 @@
 ## REVISION: a change in the REVISION number is made for any other type of change
 ##  that does not justify a change to MINOR or MAJOR
 ##
-ACTIVEMQ_LIBRARY_VERSION=4:1:0
+ACTIVEMQ_LIBRARY_VERSION=4:2:0
 
 AC_SUBST(ACTIVEMQ_LIBRARY_NAME)
 AC_SUBST(ACTIVEMQ_VERSION)

Modified: activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/examples/main.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/examples/main.cpp?rev=719236&r1=719235&r2=719236&view=diff
==============================================================================
--- activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/examples/main.cpp (original)
+++ activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/examples/main.cpp Thu Nov 20 06:27:14 2008
@@ -33,6 +33,7 @@
 #include <cms/MessageListener.h>
 #include <stdlib.h>
 #include <iostream>
+#include <memory>
 
 using namespace activemq::core;
 using namespace decaf::util::concurrent;
@@ -75,21 +76,15 @@
 
     virtual void run() {
 
-        ConnectionFactory* connectionFactory = NULL;
-
         try {
             // Create a ConnectionFactory
-            ConnectionFactory* connectionFactory =
-                ConnectionFactory::createCMSConnectionFactory( brokerURI );
+            auto_ptr<ConnectionFactory> connectionFactory(
+                ConnectionFactory::createCMSConnectionFactory( brokerURI ) );
 
             // Create a Connection
             connection = connectionFactory->createConnection();
             connection->start();
 
-            // free the factory, we are done with it.
-            delete connectionFactory;
-            connectionFactory = NULL;
-
             // Create a Session
             if( this->sessionTransacted ) {
                 session = connection->createSession( Session::SESSION_TRANSACTED );
@@ -127,9 +122,6 @@
             }
 
         }catch ( CMSException& e ) {
-            delete connectionFactory;
-            connectionFactory = NULL;
-
             e.printStackTrace();
         }
     }
@@ -138,32 +130,32 @@
 
     void cleanup(){
 
-            // Destroy resources.
-            try{
-                if( destination != NULL ) delete destination;
-            }catch ( CMSException& e ) { e.printStackTrace(); }
-            destination = NULL;
-
-            try{
-                if( producer != NULL ) delete producer;
-            }catch ( CMSException& e ) { e.printStackTrace(); }
-            producer = NULL;
-
-            // Close open resources.
-            try{
-                if( session != NULL ) session->close();
-                if( connection != NULL ) connection->close();
-            }catch ( CMSException& e ) { e.printStackTrace(); }
-
-            try{
-                if( session != NULL ) delete session;
-            }catch ( CMSException& e ) { e.printStackTrace(); }
-            session = NULL;
-
-            try{
-                if( connection != NULL ) delete connection;
-            }catch ( CMSException& e ) { e.printStackTrace(); }
-            connection = NULL;
+        // Destroy resources.
+        try{
+            if( destination != NULL ) delete destination;
+        }catch ( CMSException& e ) { e.printStackTrace(); }
+        destination = NULL;
+
+        try{
+            if( producer != NULL ) delete producer;
+        }catch ( CMSException& e ) { e.printStackTrace(); }
+        producer = NULL;
+
+        // Close open resources.
+        try{
+            if( session != NULL ) session->close();
+            if( connection != NULL ) connection->close();
+        }catch ( CMSException& e ) { e.printStackTrace(); }
+
+        try{
+            if( session != NULL ) delete session;
+        }catch ( CMSException& e ) { e.printStackTrace(); }
+        session = NULL;
+
+        try{
+            if( connection != NULL ) delete connection;
+        }catch ( CMSException& e ) { e.printStackTrace(); }
+        connection = NULL;
     }
 };
 
@@ -211,22 +203,15 @@
 
     virtual void run() {
 
-        ConnectionFactory* connectionFactory = NULL;
-
         try {
 
             // Create a ConnectionFactory
-            connectionFactory =
-                ConnectionFactory::createCMSConnectionFactory( brokerURI );
+            auto_ptr<ConnectionFactory> connectionFactory(
+                ConnectionFactory::createCMSConnectionFactory( brokerURI ) );
 
             // Create a Connection
             connection = connectionFactory->createConnection();
-
-            delete connectionFactory;
-            connectionFactory = NULL;
-
             connection->start();
-
             connection->setExceptionListener(this);
 
             // Create a Session
@@ -257,14 +242,11 @@
             // Wait while asynchronous messages come in.
             doneLatch.await( waitMillis );
 
-        } catch (CMSException& e) {
+        } catch( CMSException& e ) {
 
             // Indicate we are ready for messages.
             latch.countDown();
 
-            delete connectionFactory;
-            connectionFactory = NULL;
-
             e.printStackTrace();
         }
     }

Modified: activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/connector/openwire/commands/Message.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/connector/openwire/commands/Message.cpp?rev=719236&r1=719235&r2=719236&view=diff
==============================================================================
--- activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/connector/openwire/commands/Message.cpp (original)
+++ activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/connector/openwire/commands/Message.cpp Thu Nov 20 06:27:14 2008
@@ -458,10 +458,10 @@
 ////////////////////////////////////////////////////////////////////////////////
 unsigned int Message::getSize() const {
 
-    long long size = DEFAULT_MESSAGE_SIZE;
+    unsigned int size = DEFAULT_MESSAGE_SIZE;
 
-    size += this->getContent().size();
-    size += this->getMarshalledProperties().size();
+    size += (unsigned int)this->getContent().size();
+    size += (unsigned int)this->getMarshalledProperties().size();
 
     return size;
 }

Modified: activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/core/ActiveMQConnectionFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/core/ActiveMQConnectionFactory.cpp?rev=719236&r1=719235&r2=719236&view=diff
==============================================================================
--- activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/core/ActiveMQConnectionFactory.cpp (original)
+++ activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/core/ActiveMQConnectionFactory.cpp Thu Nov 20 06:27:14 2008
@@ -19,11 +19,13 @@
 #include <decaf/util/UUID.h>
 #include <decaf/util/Properties.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <activemq/exceptions/ExceptionDefines.h>
 #include <activemq/connector/ConnectorFactoryMap.h>
 #include <activemq/transport/TransportBuilder.h>
 #include <activemq/core/ActiveMQConnection.h>
 #include <activemq/core/ActiveMQConstants.h>
 #include <activemq/support/LibraryInit.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -95,18 +97,16 @@
        throw ( cms::CMSException ) {
 
     // Declared here so that they can be deleted in the catch block
-    Properties* properties = NULL;
-    Transport* transport = NULL;
-    Connector* connector = NULL;
-    ActiveMQConnectionData* connectionData = NULL;
-    ActiveMQConnection* connection = NULL;
+    auto_ptr<Properties> properties( new Properties() );
+    auto_ptr<Transport> transport;
+    auto_ptr<Connector> connector;
+    auto_ptr<ActiveMQConnectionData> connectionData;
+    auto_ptr<ActiveMQConnection> connection;
     std::string clientIdLocal = clientId;
     TransportBuilder transportBuilder;
 
     try{
 
-        properties = new Properties;
-
         // if no Client Id specified, create one
         if( clientIdLocal == "" ) {
             clientIdLocal = UUID::randomUUID().toString();
@@ -124,9 +124,9 @@
                 ActiveMQConstants::PARAM_CLIENTID ), clientIdLocal );
 
         // Use the TransportBuilder to get our Transport
-        transport = transportBuilder.buildTransport( url, *properties );
+        transport.reset( transportBuilder.buildTransport( url, *properties ) );
 
-        if( transport == NULL ){
+        if( transport.get() == NULL ){
             throw ActiveMQException(
                 __FILE__, __LINE__,
                 "ActiveMQConnectionFactory::createConnection - "
@@ -149,9 +149,9 @@
         }
 
         // Create the Connector.
-        connector = connectorfactory->createConnector( *properties, transport );
+        connector.reset( connectorfactory->createConnector( *properties, transport.get() ) );
 
-        if( connector == NULL ) {
+        if( connector.get() == NULL ) {
             throw ActiveMQException(
                 __FILE__, __LINE__,
                 "ActiveMQConnectionFactory::createConnection - "
@@ -162,35 +162,15 @@
         connector->start();
 
         // Create Holder and store the data for the Connection
-        connectionData = new ActiveMQConnectionData(
-            connector, transport, properties );
+        connectionData.reset( new ActiveMQConnectionData(
+            connector.release(), transport.release(), properties.release() ) );
 
         // Create and Return the new connection object.
-        connection = new ActiveMQConnection( connectionData );
-
-        return connection;
-
-    } catch( exceptions::ActiveMQException& ex ) {
-        ex.setMark( __FILE__, __LINE__ );
-
-        delete connection;
-        delete connector;
-        delete transport;
-        delete properties;
-
-        throw ex;
-
-    } catch( ... ) {
-        exceptions::ActiveMQException ex(
-            __FILE__, __LINE__,
-            "ActiveMQConnectionFactory::create - "
-            "caught unknown exception" );
-
-        delete connection;
-        delete connector;
-        delete transport;
-        delete properties;
+        connection.reset( new ActiveMQConnection( connectionData.release() ) );
 
-        throw ex;
+        return connection.release();
     }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
 }

Modified: activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/transport/MockTransport.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/transport/MockTransport.cpp?rev=719236&r1=719235&r2=719236&view=diff
==============================================================================
--- activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/transport/MockTransport.cpp (original)
+++ activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/transport/MockTransport.cpp Thu Nov 20 06:27:14 2008
@@ -37,7 +37,7 @@
     this->exceptionListener = NULL;
     this->responseBuilder = responseBuilder;
     this->own = own;
-    this->nextCommandId = 0;
+    this->nextCommandId.set( 0 );
     this->instance = this;
 
     // Configure the Internal Listener this is the Fake Broker.
@@ -57,25 +57,6 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-unsigned int MockTransport::getNextCommandId()
-    throw ( activemq::exceptions::ActiveMQException ) {
-
-    try{
-
-        synchronized( &commandIdMutex ){
-            return ++nextCommandId;
-        }
-
-        // Should never get here, but some compilers aren't
-        // smart enough to figure out we'll never get here.
-        return 0;
-    }
-    AMQ_CATCH_RETHROW( ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
-    AMQ_CATCHALL_THROW( ActiveMQException )
-}
-
-////////////////////////////////////////////////////////////////////////////////
 void MockTransport::oneway( Command* command )
         throw( CommandIOException,
                decaf::lang::exceptions::UnsupportedOperationException) {
@@ -112,7 +93,7 @@
                 outgoingCommandListener->onCommand( command );
             }
 
-            command->setCommandId( getNextCommandId() );
+            command->setCommandId( this->nextCommandId.incrementAndGet() );
             command->setResponseRequired( true );
             return responseBuilder->buildResponse( command );
         }

Modified: activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/transport/MockTransport.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/transport/MockTransport.h?rev=719236&r1=719235&r2=719236&view=diff
==============================================================================
--- activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/transport/MockTransport.h (original)
+++ activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/main/activemq/transport/MockTransport.h Thu Nov 20 06:27:14 2008
@@ -26,11 +26,10 @@
 #include <activemq/transport/CommandIOException.h>
 
 #include <decaf/lang/Thread.h>
-#include <decaf/util/concurrent/Concurrent.h>
-#include <decaf/util/concurrent/Mutex.h>
 #include <decaf/util/Queue.h>
-#include <decaf/util/concurrent/CountDownLatch.h>
 #include <decaf/util/concurrent/Concurrent.h>
+#include <decaf/util/concurrent/atomic/AtomicInteger.h>
+#include <decaf/util/concurrent/CountDownLatch.h>
 
 #include <cms/Message.h>
 
@@ -105,7 +104,7 @@
 
         public:
 
-            InternalCommandListener(void) : startedLatch(1) {
+            InternalCommandListener() : startedLatch(1) {
                 transport = NULL;
                 responseBuilder = NULL;
                 done = false;
@@ -179,8 +178,7 @@
         CommandListener* commandListener;
         CommandListener* outgoingCommandListener;
         TransportExceptionListener* exceptionListener;
-        unsigned int nextCommandId;
-        decaf::util::concurrent::Mutex commandIdMutex;
+        decaf::util::concurrent::atomic::AtomicInteger nextCommandId;
         bool own;
         InternalCommandListener internalListener;
         static MockTransport* instance;
@@ -285,10 +283,6 @@
             return NULL;
         }
 
-    protected:
-
-        unsigned int getNextCommandId() throw( exceptions::ActiveMQException );
-
     };
 
 }}

Modified: activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp?rev=719236&r1=719235&r2=719236&view=diff
==============================================================================
--- activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp (original)
+++ activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp Thu Nov 20 06:27:14 2008
@@ -26,7 +26,9 @@
 #include <activemq/transport/TransportFactoryMapRegistrar.h>
 #include <activemq/transport/MockTransportFactory.h>
 #include <activemq/connector/Connector.h>
+#include <memory>
 
+using namespace std;
 using namespace activemq;
 using namespace activemq::core;
 
@@ -159,3 +161,21 @@
 
     CPPUNIT_ASSERT( false );
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQConnectionFactoryTest::testExceptionOnCreate() {
+    try
+    {
+        std::string URI =
+            "tcp://127.0.0.2:23232&wireFormat=openwire";
+
+        ActiveMQConnectionFactory connectionFactory( URI );
+
+        auto_ptr<cms::Connection> connection(
+            connectionFactory.createConnection() );
+
+        CPPUNIT_ASSERT( false );
+    }
+    AMQ_CATCH_NOTHROW( exceptions::ActiveMQException )
+    AMQ_CATCHALL_NOTHROW( )
+}

Modified: activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/test/activemq/core/ActiveMQConnectionFactoryTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/test/activemq/core/ActiveMQConnectionFactoryTest.h?rev=719236&r1=719235&r2=719236&view=diff
==============================================================================
--- activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/test/activemq/core/ActiveMQConnectionFactoryTest.h (original)
+++ activemq/activemq-cpp/tags/activemq-cpp-2.2.2/src/test/activemq/core/ActiveMQConnectionFactoryTest.h Thu Nov 20 06:27:14 2008
@@ -31,6 +31,7 @@
         CPPUNIT_TEST( test2WithStomp );
         CPPUNIT_TEST( test1WithOpenWire );
         CPPUNIT_TEST( test2WithOpenWire );
+        CPPUNIT_TEST( testExceptionOnCreate );
         CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -50,6 +51,7 @@
         void test2WithStomp();
         void test1WithOpenWire();
         void test2WithOpenWire();
+        void testExceptionOnCreate();
 
     };