qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1527802 - /qpid/trunk/qpid/cpp/examples/messaging/hello_world.cpp
Date Mon, 30 Sep 2013 22:20:35 GMT
Author: chug
Date: Mon Sep 30 22:20:34 2013
New Revision: 1527802

URL: http://svn.apache.org/r1527802
Log:
QPID-5196: Messaging example hello_world core dumps when given a bad connection option
Move connection constructor into try-catch block


Modified:
    qpid/trunk/qpid/cpp/examples/messaging/hello_world.cpp

Modified: qpid/trunk/qpid/cpp/examples/messaging/hello_world.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/examples/messaging/hello_world.cpp?rev=1527802&r1=1527801&r2=1527802&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/examples/messaging/hello_world.cpp (original)
+++ qpid/trunk/qpid/cpp/examples/messaging/hello_world.cpp Mon Sep 30 22:20:34 2013
@@ -33,9 +33,9 @@ int main(int argc, char** argv) {
     std::string broker = argc > 1 ? argv[1] : "localhost:5672";
     std::string address = argc > 2 ? argv[2] : "amq.topic";
     std::string connectionOptions = argc > 3 ? argv[3] : "";
-    
-    Connection connection(broker, connectionOptions);
+
     try {
+        Connection connection(broker, connectionOptions);
         connection.open();
         Session session = connection.createSession();
 
@@ -47,12 +47,11 @@ int main(int argc, char** argv) {
         Message message = receiver.fetch(Duration::SECOND * 1);
         std::cout << message.getContent() << std::endl;
         session.acknowledge();
-        
+
         connection.close();
         return 0;
     } catch(const std::exception& error) {
         std::cerr << error.what() << std::endl;
-        connection.close();
-        return 1;   
+        return 1;
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message