You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jb...@apache.org on 2016/04/04 18:09:48 UTC

[39/42] activemq-artemis git commit: ARTEMIS-464 Sending null textMessage shouldn't break the wire

ARTEMIS-464 Sending null textMessage shouldn't break the wire


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/91bdeb37
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/91bdeb37
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/91bdeb37

Branch: refs/heads/master
Commit: 91bdeb3728ec2aba78b1f700d056f3940589ac7b
Parents: 3560415
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Apr 1 19:51:17 2016 -0400
Committer: jbertram <jb...@apache.org>
Committed: Mon Apr 4 11:08:43 2016 -0500

----------------------------------------------------------------------
 .../openwire/OpenWireMessageConverter.java      |  8 +++++--
 .../core/protocol/openwire/amq/AMQConsumer.java |  2 ++
 .../activemq/usecases/TopicRedeliverTest.java   | 19 ++++++++++-------
 .../openwire/SimpleOpenWireTest.java            | 22 ++++++++++++++++++++
 4 files changed, 42 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/91bdeb37/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
index b0a6d46..53464cc 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
@@ -129,9 +129,13 @@ public class OpenWireMessageConverter implements MessageConverter {
       byte coreType = toCoreType(messageSend.getDataStructureType());
       coreMessage.setType(coreType);
 
+      ActiveMQBuffer body = coreMessage.getBodyBuffer();
+
       ByteSequence contents = messageSend.getContent();
-      if (contents != null) {
-         ActiveMQBuffer body = coreMessage.getBodyBuffer();
+      if (contents == null && coreType == org.apache.activemq.artemis.api.core.Message.TEXT_TYPE) {
+         body.writeNullableString(null);
+      }
+      else if (contents != null) {
          boolean messageCompressed = messageSend.isCompressed();
          if (messageCompressed) {
             coreMessage.putBooleanProperty(AMQ_MSG_COMPRESSED, messageCompressed);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/91bdeb37/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
index 7a06c73..3093ed8 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
@@ -193,9 +193,11 @@ public class AMQConsumer {
          return size;
       }
       catch (IOException e) {
+         e.printStackTrace();
          return 0;
       }
       catch (Throwable t) {
+         t.printStackTrace();
          return 0;
       }
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/91bdeb37/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicRedeliverTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicRedeliverTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicRedeliverTest.java
index 2c8f958..03e7b9f 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicRedeliverTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicRedeliverTest.java
@@ -78,19 +78,24 @@ public class TopicRedeliverTest extends TestSupport {
 
       TextMessage sent1 = producerSession.createTextMessage();
       sent1.setText("msg1");
+      sent1.setStringProperty("str", "1");
       producer.send(sent1);
 
       TextMessage sent2 = producerSession.createTextMessage();
-      sent1.setText("msg2");
+      sent2.setText("msg2");
+      sent2.setStringProperty("str", "2");
       producer.send(sent2);
 
       TextMessage sent3 = producerSession.createTextMessage();
-      sent1.setText("msg3");
+      sent2.setText("msg3");
+      sent2.setStringProperty("str", "3");
       producer.send(sent3);
 
-      consumer.receive(RECEIVE_TIMEOUT);
-      Message rec2 = consumer.receive(RECEIVE_TIMEOUT);
-      consumer.receive(RECEIVE_TIMEOUT);
+      TextMessage msgTest = (TextMessage)consumer.receive(RECEIVE_TIMEOUT);
+      System.out.println("msgTest::" + msgTest + " // " + msgTest.getText());
+      TextMessage rec2 = (TextMessage)consumer.receive(RECEIVE_TIMEOUT);
+      System.out.println("msgTest::" + rec2 + " // " + rec2.getText());
+      assertNull(consumer.receiveNoWait());
 
       // ack rec2
       rec2.acknowledge();
@@ -99,10 +104,10 @@ public class TopicRedeliverTest extends TestSupport {
       sent4.setText("msg4");
       producer.send(sent4);
 
-      Message rec4 = consumer.receive(RECEIVE_TIMEOUT);
+      TextMessage rec4 = (TextMessage)consumer.receive(RECEIVE_TIMEOUT);
       assertTrue(rec4.equals(sent4));
       consumerSession.recover();
-      rec4 = consumer.receive(RECEIVE_TIMEOUT);
+      rec4 = (TextMessage)consumer.receive(RECEIVE_TIMEOUT);
       assertTrue(rec4.equals(sent4));
       assertTrue(rec4.getJMSRedelivered());
       rec4.acknowledge();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/91bdeb37/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java
index c4aea03..82d8242 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java
@@ -93,6 +93,28 @@ public class SimpleOpenWireTest extends BasicOpenWireTest {
    }
 
    @Test
+   public void testSendEmpty() throws Exception {
+      try (Connection connection = factory.createConnection()) {
+
+         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         Queue queue = session.createQueue(queueName);
+         System.out.println("Queue:" + queue);
+         MessageProducer producer = session.createProducer(queue);
+         MessageConsumer consumer = session.createConsumer(queue);
+         producer.send(session.createTextMessage());
+
+         Assert.assertNull(consumer.receive(100));
+         connection.start();
+
+         TextMessage message = (TextMessage) consumer.receive(5000);
+
+         Assert.assertNotNull(message);
+
+         message.acknowledge();
+      }
+   }
+
+   @Test
    public void testXASimple() throws Exception {
       XAConnection connection = xaFactory.createXAConnection();