activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1005586 - in /activemq/activemq-cpp/trunk/activemq-c/src/main/c: CMS_Connection.cpp CMS_ConnectionFactory.cpp CMS_Destination.cpp CMS_MessageConsumer.cpp
Date Thu, 07 Oct 2010 19:38:17 GMT
Author: tabish
Date: Thu Oct  7 19:38:17 2010
New Revision: 1005586

URL: http://svn.apache.org/viewvc?rev=1005586&view=rev
Log:
Add some additional error checks for NULL conditions.

Modified:
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.cpp
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_ConnectionFactory.cpp
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.cpp
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp

Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.cpp?rev=1005586&r1=1005585&r2=1005586&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.cpp Thu Oct  7 19:38:17
2010
@@ -65,7 +65,12 @@ cms_status createConnection(CMS_Connecti
         if (factory == NULL) {
             result = CMS_ERROR;
         } else {
-            wrapper->connection = factory->factory->createConnection(username, password,
clientId);
+
+            std::string user = username == NULL ? "" : std::string(username);
+            std::string pass = password == NULL ? "" : std::string(password);
+            std::string id = clientId == NULL ? "" : std::string(clientId);
+
+            wrapper->connection = factory->factory->createConnection(user, pass,
id);
             *connection = wrapper.release();
         }
 

Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_ConnectionFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_ConnectionFactory.cpp?rev=1005586&r1=1005585&r2=1005586&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_ConnectionFactory.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_ConnectionFactory.cpp Thu Oct  7
19:38:17 2010
@@ -37,6 +37,9 @@ cms_status createDefaultConnectionFactor
     try{
         wrapper->factory = new activemq::core::ActiveMQConnectionFactory();
         *factory = wrapper.release();
+    } catch(cms::CMSException& ex) {
+        ex.printStackTrace();
+        result = CMS_ERROR;
     } catch(...) {
         result = CMS_ERROR;
     }
@@ -58,11 +61,21 @@ cms_status createConnectionFactory(CMS_C
         if (brokerUri == NULL) {
             wrapper->factory = new activemq::core::ActiveMQConnectionFactory();
         } else {
-            wrapper->factory = new activemq::core::ActiveMQConnectionFactory( brokerUri,
username, password );
+
+            std::string user = username == NULL ? "" : std::string(username);
+            std::string pass = password == NULL ? "" : std::string(password);
+
+            wrapper->factory = new activemq::core::ActiveMQConnectionFactory( brokerUri,
user, pass );
         }
 
         *factory = wrapper.release();
+    } catch(cms::CMSException& ex) {
+        ex.printStackTrace();
+        result = CMS_ERROR;
+    } catch(std::exception& ex) {
+        std::cout << ex.what() << std::endl;
     } catch(...) {
+        std::cout << "Caught an unknown exception." << std::endl;
         result = CMS_ERROR;
     }
 

Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.cpp?rev=1005586&r1=1005585&r2=1005586&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.cpp Thu Oct  7 19:38:17
2010
@@ -41,23 +41,28 @@ cms_status createDestination(CMS_Session
             result = CMS_ERROR;
         } else {
 
-            switch(type) {
-                case CMS_TOPIC:
-                    wrapper->destination = session->session->createTopic(name);
-                    break;
-                case CMS_TEMPORARY_TOPIC:
-                    wrapper->destination = session->session->createTemporaryTopic();
-                    break;
-                case CMS_TEMPORARY_QUEUE:
-                    wrapper->destination = session->session->createTemporaryQueue();
-                    break;
-                default:
-                    wrapper->destination = session->session->createQueue(name);
-                    break;
-            }
+            if (name == NULL && type != CMS_TEMPORARY_QUEUE && type != CMS_TEMPORARY_TOPIC)
{
+                result = CMS_ERROR;
+            } else {
+
+                switch(type) {
+                    case CMS_TOPIC:
+                        wrapper->destination = session->session->createTopic(name);
+                        break;
+                    case CMS_TEMPORARY_TOPIC:
+                        wrapper->destination = session->session->createTemporaryTopic();
+                        break;
+                    case CMS_TEMPORARY_QUEUE:
+                        wrapper->destination = session->session->createTemporaryQueue();
+                        break;
+                    default:
+                        wrapper->destination = session->session->createQueue(name);
+                        break;
+                }
 
-            wrapper->type = type;
-            *destination = wrapper.release();
+                wrapper->type = type;
+                *destination = wrapper.release();
+            }
         }
 
     } catch(...) {

Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp?rev=1005586&r1=1005585&r2=1005586&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp Thu Oct  7 19:38:17
2010
@@ -59,8 +59,11 @@ cms_status createConsumer(CMS_Session* s
         if (session == NULL || destination == NULL) {
             result = CMS_ERROR;
         } else {
+
+            std::string sel = selector == NULL ? "" : std::string(selector);
+
             wrapper->consumer = session->session->createConsumer(
-                destination->destination, selector, noLocal > 0 ? true : false);
+                destination->destination, sel, noLocal > 0 ? true : false);
             *consumer = wrapper.release();
         }
 
@@ -94,8 +97,11 @@ cms_status createDurableConsumer(CMS_Ses
 
                 cms::Topic* topic = dynamic_cast<cms::Topic*>(destination->destination);
 
+                std::string name = subscriptionName == NULL ? "" : std::string(subscriptionName);
+                std::string sel = selector == NULL ? "" : std::string(selector);
+
                 wrapper->consumer = session->session->createDurableConsumer(
-                    topic, subscriptionName, selector, noLocal > 0 ? true : false);
+                    topic, name, sel, noLocal > 0 ? true : false);
 
                 *consumer = wrapper.release();
             }



Mime
View raw message