Return-Path: X-Original-To: apmail-qpid-commits-archive@www.apache.org Delivered-To: apmail-qpid-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B84B9108C2 for ; Mon, 30 Sep 2013 22:20:58 +0000 (UTC) Received: (qmail 2856 invoked by uid 500); 30 Sep 2013 22:20:58 -0000 Delivered-To: apmail-qpid-commits-archive@qpid.apache.org Received: (qmail 2838 invoked by uid 500); 30 Sep 2013 22:20:58 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 2831 invoked by uid 99); 30 Sep 2013 22:20:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Sep 2013 22:20:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Sep 2013 22:20:56 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 49F932388860; Mon, 30 Sep 2013 22:20:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1527802 - /qpid/trunk/qpid/cpp/examples/messaging/hello_world.cpp Date: Mon, 30 Sep 2013 22:20:35 -0000 To: commits@qpid.apache.org From: chug@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130930222035.49F932388860@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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