You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2014/09/26 16:00:32 UTC

git commit: Fix issue with clearing destination bits when called with null

Repository: qpid-jms
Updated Branches:
  refs/heads/master 191fa4ce1 -> dc40b09c9


Fix issue with clearing destination bits when called with null

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

Branch: refs/heads/master
Commit: dc40b09c918c1253ddd20fa1b6b08252ae47b182
Parents: 191fa4c
Author: Timothy Bish <ta...@gmail.com>
Authored: Fri Sep 26 10:00:01 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Fri Sep 26 10:00:01 2014 -0400

----------------------------------------------------------------------
 .../provider/amqp/message/AmqpDestinationHelper.java  | 14 ++------------
 .../amqp/message/AmqpDestinationHelperTest.java       | 14 ++++++--------
 2 files changed, 8 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/dc40b09c/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
index a7ac472..fdc9a75 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
@@ -135,12 +135,7 @@ public class AmqpDestinationHelper {
     }
 
     public void setToAddressFromDestination(AmqpJmsMessageFacade message, JmsDestination destination) {
-        //TODO: don't we need to clear any existing value and type annotation?
-        if (destination == null) {
-            return;
-        }
-
-        String address = destination.getName();
+        String address = destination != null ? destination.getName() : null;
         String typeString = toTypeAnnotation(destination);
 
         message.setToAddress(address);
@@ -153,12 +148,7 @@ public class AmqpDestinationHelper {
     }
 
     public void setReplyToAddressFromDestination(AmqpJmsMessageFacade message, JmsDestination destination) {
-        //TODO: don't we need to clear any existing value and type annotation?
-        if (destination == null) {
-            return;
-        }
-
-        String replyToAddress = destination.getName();
+        String replyToAddress = destination != null ? destination.getName() : null;
         String typeString = toTypeAnnotation(destination);
 
         message.setReplyToAddress(replyToAddress);

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/dc40b09c/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
index fbd0948..49fc17d 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
@@ -328,14 +328,13 @@ public class AmqpDestinationHelperTest {
     public void testSetToAddressFromDestinationWithNullDestination() {
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         helper.setToAddressFromDestination(message, null);
-        Mockito.verifyZeroInteractions(message);
+        Mockito.verify(message).setToAddress(null);
+        Mockito.verify(message).removeAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
     }
 
-    @Test
+    @Test(expected=NullPointerException.class)
     public void testSetToAddressFromDestinationWithNullDestinationAndNullMessage() {
-        AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         helper.setToAddressFromDestination(null, null);
-        Mockito.verifyZeroInteractions(message);
     }
 
     @Test(expected=NullPointerException.class)
@@ -398,14 +397,13 @@ public class AmqpDestinationHelperTest {
     public void testSetReplyToAddressFromDestinationWithNullDestination() {
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         helper.setReplyToAddressFromDestination(message, null);
-        Mockito.verifyZeroInteractions(message);
+        Mockito.verify(message).setReplyToAddress(null);
+        Mockito.verify(message).removeAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
     }
 
-    @Test
+    @Test(expected=NullPointerException.class)
     public void testSetReplyToAddressFromDestinationWithNullDestinationAndNullMessage() {
-        AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         helper.setReplyToAddressFromDestination(null, null);
-        Mockito.verifyZeroInteractions(message);
     }
 
     @Test(expected=NullPointerException.class)


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