You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by nm...@apache.org on 2007/01/29 13:47:11 UTC

svn commit: r501029 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main: activemq/core/ActiveMQConsumer.cpp activemq/core/ActiveMQConsumer.h activemq/exceptions/ActiveMQException.h cms/CMSException.h

Author: nmittler
Date: Mon Jan 29 04:47:10 2007
New Revision: 501029

URL: http://svn.apache.org/viewvc?view=rev&rev=501029
Log:
[AMQCPP-61] - Fixing return of temporary reference from CMSException.what()

Modified:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/exceptions/ActiveMQException.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSException.h

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp?view=diff&rev=501029&r1=501028&r2=501029
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp Mon Jan 29 04:47:10 2007
@@ -50,7 +50,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQConsumer::~ActiveMQConsumer(void)
+ActiveMQConsumer::~ActiveMQConsumer()
 {
     try
     {
@@ -71,7 +71,8 @@
             closed = true;
             
             // Identifies any errors encountered during shutdown.
-            ActiveMQException* error = NULL; 
+            bool haveException = false;
+            ActiveMQException error; 
             
             // Dispose of the Consumer Info, this should stop us from getting
             // any more messages.  This may result in message traffic
@@ -80,39 +81,41 @@
             // and continue to shutdown normally.
             try{
                 session->onDestroySessionResource( this );
-            } catch( cms::CMSException& ex ){                 
-                error = new ActiveMQException( __FILE__, __LINE__, 
-                        ex.what() );
+            } catch( ActiveMQException& ex ){
+                if( !haveException ){ 
+                    ex.setMark( __FILE__, __LINE__ );                
+                    error = ex;
+                    haveException = true;
+                }
             }
             
             // Stop the asynchronous message processin thread if it's
             // running.
             try{
                 stopThread();
-            } catch ( ... ){
-                if( error != NULL ){
-                    error = new ActiveMQException( __FILE__, __LINE__, 
-                        "failed to stop the thread" );
+            } catch ( ActiveMQException& ex ){
+                if( !haveException ){ 
+                    ex.setMark( __FILE__, __LINE__ );                
+                    error = ex;
+                    haveException = true;
                 }
             }
             
             // Purge all the pending messages
             try{
                 purgeMessages();
-            } catch ( ... ){
-                if( error != NULL ){
-                    error = new ActiveMQException( __FILE__, __LINE__, 
-                        "failed to purge messages from the queue" );
+            } catch ( ActiveMQException& ex ){
+                if( !haveException ){ 
+                    ex.setMark( __FILE__, __LINE__ );                
+                    error = ex;
+                    haveException = true;
                 }
             }
             
             // If we encountered an error, propagate it.
-            if( error != NULL ){
-                ActiveMQException ex( *error );
-                delete error;
-                
-                ex.setMark( __FILE__, __LINE__ );
-                throw ex;
+            if( haveException ){
+                error.setMark( __FILE__, __LINE__ );
+                throw error;
             }
                                   
         }
@@ -122,7 +125,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string ActiveMQConsumer::getMessageSelector(void) const 
+std::string ActiveMQConsumer::getMessageSelector() const 
     throw ( cms::CMSException )
 {
     try
@@ -238,7 +241,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-cms::Message* ActiveMQConsumer::receiveNoWait(void) 
+cms::Message* ActiveMQConsumer::receiveNoWait() 
     throw ( cms::CMSException )
 {
     try
@@ -325,7 +328,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQConsumer::run(void)
+void ActiveMQConsumer::run()
 {
     try
     {
@@ -423,7 +426,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQConsumer::purgeMessages(void)
+void ActiveMQConsumer::purgeMessages() throw (ActiveMQException)
 {
     try
     {
@@ -462,7 +465,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQConsumer::notifyListener( Message* message ){
+void ActiveMQConsumer::notifyListener( Message* message ) throw (ActiveMQException){
     
     try
     {
@@ -481,7 +484,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQConsumer::destroyMessage( Message* message ){
+void ActiveMQConsumer::destroyMessage( Message* message ) throw (ActiveMQException){
     
     try
     {
@@ -499,7 +502,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQConsumer::startThread(){
+void ActiveMQConsumer::startThread() throw (ActiveMQException) {
     
     try
     {
@@ -521,7 +524,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQConsumer::stopThread(){
+void ActiveMQConsumer::stopThread() throw (ActiveMQException) {
     
     try
     {

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.h?view=diff&rev=501029&r1=501028&r2=501029
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.h Mon Jan 29 04:47:10 2007
@@ -77,7 +77,7 @@
         ActiveMQConsumer( connector::ConsumerInfo* consumerInfo,
                           ActiveMQSession* session );
 
-        virtual ~ActiveMQConsumer(void);
+        virtual ~ActiveMQConsumer();
 
     public:  // Interface Implementation
 
@@ -95,7 +95,7 @@
          * @return new message
          * @throws CMSException
          */
-        virtual cms::Message* receive(void) throw ( cms::CMSException );
+        virtual cms::Message* receive() throw ( cms::CMSException );
 
         /**
          * Synchronously Receive a Message, time out after defined interval.
@@ -112,7 +112,7 @@
          * @return new message
          * @throws CMSException
          */
-        virtual cms::Message* receiveNoWait(void) throw ( cms::CMSException );
+        virtual cms::Message* receiveNoWait() throw ( cms::CMSException );
 
         /**
          * Sets the MessageListener that this class will send notifs on
@@ -124,7 +124,7 @@
          * Gets the MessageListener that this class will send notifs on
          * @param MessageListener interface pointer
          */
-        virtual cms::MessageListener* getMessageListener(void) const {
+        virtual cms::MessageListener* getMessageListener() const {
             return this->listener;
         }
 
@@ -133,7 +133,7 @@
          * @return This Consumer's selector expression or "".
          * @throws cms::CMSException
          */
-        virtual std::string getMessageSelector(void) const 
+        virtual std::string getMessageSelector() const 
           throw ( cms::CMSException );
           
         /**
@@ -154,7 +154,7 @@
          * onMessage method, but if it does happen this function will get any
          * registered exception listener from the session and notify it.
          */            
-        virtual void run(void);
+        virtual void run();
 
     public:  // ActiveMQMessageListener Methods
     
@@ -174,7 +174,7 @@
          * this Session resource.
          * @return pointer to a Connector Resource, can be NULL
          */
-        virtual connector::ConnectorResource* getConnectorResource(void) {
+        virtual connector::ConnectorResource* getConnectorResource() {
             return consumerInfo;
         }
 
@@ -195,7 +195,7 @@
          * Get the Consumer information for this consumer
          * @return Pointer to a Consumer Info Object            
          */
-        virtual connector::ConsumerInfo* getConsumerInfo(void) {
+        virtual connector::ConsumerInfo* getConsumerInfo() {
             return consumerInfo;
         }
 
@@ -205,20 +205,22 @@
          * Purges all messages currently in the queue.  This can be as a
          * result of a rollback, or of the consumer being shutdown.
          */
-        virtual void purgeMessages(void);
+        virtual void purgeMessages() throw (exceptions::ActiveMQException);
         
         /**
          * Destroys the message if the session is transacted, otherwise
          * does nothing.
          * @param message the message to destroy
          */
-        virtual void destroyMessage( cms::Message* message );
+        virtual void destroyMessage( cms::Message* message ) 
+            throw (exceptions::ActiveMQException);
 
         /**
          * Notifies the listener of a message.
          * @param message the message to pass to the listener
          */
-        void notifyListener( cms::Message* message );
+        void notifyListener( cms::Message* message ) 
+            throw (exceptions::ActiveMQException);
         
         /**
          * Starts the message processing thread to receive messages
@@ -226,12 +228,12 @@
          * is invoked, which means that the caller is choosing to use this
          * consumer asynchronously instead of synchronously (receive).
          */
-        void startThread();
+        void startThread() throw (exceptions::ActiveMQException);
         
         /**
          * Stops the asynchronous message processing thread if it's started.
          */
-        void stopThread();
+        void stopThread() throw (exceptions::ActiveMQException);
 
     };
 

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/exceptions/ActiveMQException.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/exceptions/ActiveMQException.h?view=diff&rev=501029&r1=501028&r2=501029
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/exceptions/ActiveMQException.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/exceptions/ActiveMQException.h Mon Jan 29 04:47:10 2007
@@ -75,7 +75,15 @@
         virtual std::string getMessage() const{ 
             return message; 
         }
-   
+
+        /**
+         * Implement method from std::exception
+         * @return the const char* of <code>getMessage()</code>.
+         */
+        virtual const char* what () const throw (){
+            return message.c_str();
+        }
+           
         /**
          * Sets the cause for this exception.
          * @param msg the format string for the msg.

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSException.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSException.h?view=diff&rev=501029&r1=501028&r2=501029
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSException.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSException.h Mon Jan 29 04:47:10 2007
@@ -45,14 +45,6 @@
         virtual std::string getMessage() const = 0;
         
         /**
-         * Implement method from std::exception
-         * @return the const char* of <code>getMessage()</code>.
-         */
-        virtual const char * what () const throw (){
-            return getMessage().c_str();
-        }
-        
-        /**
          * Provides the stack trace for every point where
          * this exception was caught, marked, and rethrown.
          * @return vector containing stack trace strings