qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject qpid-jms git commit: update HelloWorld example to prevent NPE if the message is not received
Date Sat, 07 Mar 2015 11:54:10 GMT
Repository: qpid-jms
Updated Branches:
  refs/heads/master 96917fde6 -> 1b3f44cee


update HelloWorld example to prevent NPE if the message is not received


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/1b3f44ce
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/1b3f44ce
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/1b3f44ce

Branch: refs/heads/master
Commit: 1b3f44cee25893c1566998a62ea09dd8eddd2282
Parents: 96917fd
Author: Robert Gemmell <robbie@apache.org>
Authored: Sat Mar 7 11:50:11 2015 +0000
Committer: Robert Gemmell <robbie@apache.org>
Committed: Sat Mar 7 11:53:36 2015 +0000

----------------------------------------------------------------------
 .../src/main/java/org/apache/qpid/jms/example/HelloWorld.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/1b3f44ce/qpid-jms-examples/src/main/java/org/apache/qpid/jms/example/HelloWorld.java
----------------------------------------------------------------------
diff --git a/qpid-jms-examples/src/main/java/org/apache/qpid/jms/example/HelloWorld.java b/qpid-jms-examples/src/main/java/org/apache/qpid/jms/example/HelloWorld.java
index 9100c50..90ac0b7 100644
--- a/qpid-jms-examples/src/main/java/org/apache/qpid/jms/example/HelloWorld.java
+++ b/qpid-jms-examples/src/main/java/org/apache/qpid/jms/example/HelloWorld.java
@@ -60,7 +60,12 @@ public class HelloWorld {
             TextMessage message = session.createTextMessage("Hello world!");
             messageProducer.send(message, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY,
Message.DEFAULT_TIME_TO_LIVE);
             TextMessage receivedMessage = (TextMessage) messageConsumer.receive(2000L);
-            System.out.println(receivedMessage.getText());
+
+            if (receivedMessage != null) {
+                System.out.println(receivedMessage.getText());
+            } else {
+                System.out.println("No message received within the given timeout!");
+            }
 
             connection.close();
         } catch (Exception exp) {


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


Mime
View raw message