activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-817 and ARTEMIS-818 openwire fixes
Date Tue, 25 Oct 2016 16:04:37 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master ad8919dc4 -> 1ac69fd17


ARTEMIS-817 and ARTEMIS-818 openwire fixes

https://issues.apache.org/jira/browse/ARTEMIS-817
https://issues.apache.org/jira/browse/ARTEMIS-818

issues around Openwire protocol, sending a null stream maessage via openwire causes a null
pointer and if a topic is auto created with openwire then it cant be destroyed as it checks
for the management queue.


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

Branch: refs/heads/master
Commit: 1a4a148ba96996ddfa94a99de9990ff7bfb83a00
Parents: ad8919d
Author: Andy Taylor <andy.tayls67@gmail.com>
Authored: Mon Oct 24 14:41:19 2016 +0100
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Oct 25 12:00:37 2016 -0400

----------------------------------------------------------------------
 .../protocol/openwire/OpenWireConnection.java   |  9 ++++++-
 .../openwire/OpenWireMessageConverter.java      | 25 +++++++++++---------
 .../openwire/SimpleOpenWireTest.java            | 23 ++++++++++++++++++
 3 files changed, 45 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1a4a148b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index c6582bd..33418e6 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -815,7 +815,14 @@ public class OpenWireConnection extends AbstractRemotingConnection implements
Se
 
    public void removeDestination(ActiveMQDestination dest) throws Exception {
       if (dest.isQueue()) {
-         server.destroyQueue(OpenWireUtil.toCoreAddress(dest));
+         try {
+            server.destroyQueue(OpenWireUtil.toCoreAddress(dest));
+         } catch (ActiveMQNonExistentQueueException neq) {
+            //this is ok, ActiveMQ 5 allows this and will actually do it quite often
+            ActiveMQServerLogger.LOGGER.debug("queue never existed");
+         }
+
+
       } else {
          Bindings bindings = server.getPostOffice().getBindingsForAddress(OpenWireUtil.toCoreAddress(dest));
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1a4a148b/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 131cfd1..f49c972 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
@@ -499,18 +499,21 @@ public class OpenWireMessageConverter implements MessageConverter {
                }
             } else if (coreType == org.apache.activemq.artemis.api.core.Message.MAP_TYPE)
{
                TypedProperties mapData = new TypedProperties();
-               mapData.decode(buffer);
-
-               Map<String, Object> map = mapData.getMap();
-               ByteArrayOutputStream out = new ByteArrayOutputStream(mapData.getEncodeSize());
-               OutputStream os = out;
-               if (isCompressed) {
-                  os = new DeflaterOutputStream(os);
-               }
-               try (DataOutputStream dataOut = new DataOutputStream(os)) {
-                  MarshallingSupport.marshalPrimitiveMap(map, dataOut);
+               //it could be a null map
+               if (buffer.readableBytes() > 0) {
+                  mapData.decode(buffer);
+                  Map<String, Object> map = mapData.getMap();
+                  ByteArrayOutputStream out = new ByteArrayOutputStream(mapData.getEncodeSize());
+                  OutputStream os = out;
+                  if (isCompressed) {
+                     os = new DeflaterOutputStream(os);
+                  }
+                  try (DataOutputStream dataOut = new DataOutputStream(os)) {
+                     MarshallingSupport.marshalPrimitiveMap(map, dataOut);
+                  }
+                  bytes = out.toByteArray();
                }
-               bytes = out.toByteArray();
+
             } else if (coreType == org.apache.activemq.artemis.api.core.Message.OBJECT_TYPE)
{
                int len = buffer.readInt();
                bytes = new byte[len];

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1a4a148b/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 9a2b8be..81f0f1b 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
@@ -19,6 +19,7 @@ package org.apache.activemq.artemis.tests.integration.openwire;
 import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.JMSException;
+import javax.jms.MapMessage;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageListener;
@@ -128,6 +129,28 @@ public class SimpleOpenWireTest extends BasicOpenWireTest {
    }
 
    @Test
+   public void testSendNullMapMessage() 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.createMapMessage());
+
+         Assert.assertNull(consumer.receive(100));
+         connection.start();
+
+         MapMessage message = (MapMessage) consumer.receive(5000);
+
+         Assert.assertNotNull(message);
+
+         message.acknowledge();
+      }
+   }
+
+   @Test
    public void testXASimple() throws Exception {
       XAConnection connection = xaFactory.createXAConnection();
 


Mime
View raw message