You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by lq...@apache.org on 2017/08/11 14:15:06 UTC

[3/3] qpid-broker-j git commit: QPID-7434: [Java Broker] Improve handling of empty map/stream messages.

QPID-7434: [Java Broker] Improve handling of empty map/stream messages.


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/385167e1
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/385167e1
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/385167e1

Branch: refs/heads/master
Commit: 385167e1f6085aceddb2ded398ad504bb40aed98
Parents: 42bebb9
Author: Lorenz Quack <lq...@apache.org>
Authored: Fri Aug 11 10:48:16 2017 +0100
Committer: Lorenz Quack <lq...@apache.org>
Committed: Fri Aug 11 15:14:53 2017 +0100

----------------------------------------------------------------------
 .../protocol/v1_0/MessageConverter_to_1_0.java     | 11 +++++++++--
 .../MessageConverter_0_10_to_1_0Test.java          | 17 ++++++++++++++++-
 .../v0_8_v1_0/MessageConverter_0_8_to_1_0Test.java | 16 +++++++++++++++-
 3 files changed, 40 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/385167e1/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java
index 7060058..23eee80 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java
@@ -32,7 +32,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.ObjectOutputStream;
 import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -285,7 +284,15 @@ public abstract class MessageConverter_to_1_0<M extends ServerMessage> implement
         }
         else if (MessageConverter_from_1_0.TEXT_CONTENT_TYPES.matcher(mimeType).matches())
         {
-            return new AmqpValue(null);
+            return new AmqpValue("");
+        }
+        else if (MessageConverter_from_1_0.MAP_MESSAGE_CONTENT_TYPES.matcher(mimeType).matches())
+        {
+            return new AmqpValue(Collections.emptyMap());
+        }
+        else if (MessageConverter_from_1_0.LIST_MESSAGE_CONTENT_TYPES.matcher(mimeType).matches())
+        {
+            return new AmqpSequence(Collections.emptyList());
         }
         return new Data(new Binary(data));
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/385167e1/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0Test.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0Test.java b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0Test.java
index 2e8357a..2d53233 100644
--- a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0Test.java
+++ b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0Test.java
@@ -203,6 +203,13 @@ public class MessageConverter_0_10_to_1_0Test extends QpidTestCase
         doTestStreamMessage(messageBytes, mimeType, expected, JmsMessageTypeAnnotation.STREAM_MESSAGE.getType());
     }
 
+    public void testConvertJmsStreamMessageEmptyBody() throws Exception
+    {
+        final List<Object> expected = Collections.emptyList();
+
+        doTestStreamMessage(null, "jms/stream-message", expected, JmsMessageTypeAnnotation.STREAM_MESSAGE.getType());
+    }
+
     public void testConvertAmqpListMessageBody() throws Exception
     {
         final List<Object> expected = Lists.newArrayList("apple", 43, 31.42D);
@@ -237,6 +244,14 @@ public class MessageConverter_0_10_to_1_0Test extends QpidTestCase
         doTestMapMessage(messageBytes, "amqp/map", expected, JmsMessageTypeAnnotation.MAP_MESSAGE.getType());
     }
 
+    public void testConvertJmsMapMessageEmptyBody() throws Exception
+    {
+        final Map<String, Object> expected = Collections.emptyMap();
+
+        doTestMapMessage(null, "jms/map-message", expected, JmsMessageTypeAnnotation.MAP_MESSAGE.getType());
+    }
+
+
     public void testConvertAmqpMapMessageBodyWithNonJmsContent() throws Exception
     {
         final Map<String, Object> expected = Collections.singletonMap("key", Collections.singletonList("nonJmsList"));
@@ -396,7 +411,7 @@ public class MessageConverter_0_10_to_1_0Test extends QpidTestCase
     private void doTestTextMessage(final String originalContent, final String mimeType) throws Exception
     {
         final byte[] contentBytes = originalContent == null ? null : originalContent.getBytes(UTF_8);
-        String expectedContent = originalContent == null ? null : originalContent;
+        String expectedContent = originalContent == null ? "" : originalContent;
         doTest(contentBytes,
                mimeType,
                AmqpValueSection.class,

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/385167e1/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_0_8_to_1_0Test.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_0_8_to_1_0Test.java b/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_0_8_to_1_0Test.java
index 62dc8f4d..df1a786 100644
--- a/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_0_8_to_1_0Test.java
+++ b/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_0_8_to_1_0Test.java
@@ -202,6 +202,13 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
         doTestStreamMessage(messageBytes, mimeType, expected, JmsMessageTypeAnnotation.STREAM_MESSAGE.getType());
     }
 
+    public void testConvertJmsStreamMessageEmptyBody() throws Exception
+    {
+        final List<Object> expected = Collections.emptyList();
+
+        doTestStreamMessage(null, "jms/stream-message", expected, JmsMessageTypeAnnotation.STREAM_MESSAGE.getType());
+    }
+
     public void testConvertAmqpListMessageBody() throws Exception
     {
         final List<Object> expected = Lists.newArrayList("apple", 43, 31.42D);
@@ -228,6 +235,13 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
         doTestMapMessage(messageBytes, "jms/map-message", expected, JmsMessageTypeAnnotation.MAP_MESSAGE.getType());
     }
 
+    public void testConvertJmsMapMessageEmptyBody() throws Exception
+    {
+        final Map<String, Object> expected = Collections.emptyMap();
+
+        doTestMapMessage(null, "jms/map-message", expected, JmsMessageTypeAnnotation.MAP_MESSAGE.getType());
+    }
+
     public void testConvertAmqpMapMessageBody() throws Exception
     {
         final Map<String, Object> expected = Collections.singletonMap("key", "value");
@@ -394,7 +408,7 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
     private void doTestTextMessage(final String originalContent, final String mimeType) throws Exception
     {
         final byte[] contentBytes = originalContent == null ? null : originalContent.getBytes(UTF_8);
-        String expectedContent = originalContent == null ? null : originalContent;
+        String expectedContent = originalContent == null ? "" : originalContent;
         doTest(contentBytes,
                mimeType,
                AmqpValueSection.class,


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