activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5511 - retained message for zero-byte clientId client
Date Fri, 09 Jan 2015 11:59:06 GMT
Repository: activemq
Updated Branches:
  refs/heads/trunk f303f85ce -> 7948d6905


https://issues.apache.org/jira/browse/AMQ-5511 - retained message for zero-byte clientId client


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

Branch: refs/heads/trunk
Commit: 7948d69056be9021e07fbdb1dd158f75f52b7bf9
Parents: f303f85
Author: Dejan Bosanac <dejan@nighttale.net>
Authored: Fri Jan 9 12:50:39 2015 +0100
Committer: Dejan Bosanac <dejan@nighttale.net>
Committed: Fri Jan 9 12:58:53 2015 +0100

----------------------------------------------------------------------
 .../AbstractMQTTSubscriptionStrategy.java       |  6 ++++-
 .../activemq/transport/mqtt/MQTTTest.java       | 23 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/7948d690/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/strategy/AbstractMQTTSubscriptionStrategy.java
----------------------------------------------------------------------
diff --git a/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/strategy/AbstractMQTTSubscriptionStrategy.java
b/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/strategy/AbstractMQTTSubscriptionStrategy.java
index d77c51b..121b829 100644
--- a/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/strategy/AbstractMQTTSubscriptionStrategy.java
+++ b/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/strategy/AbstractMQTTSubscriptionStrategy.java
@@ -129,7 +129,11 @@ public abstract class AbstractMQTTSubscriptionStrategy implements MQTTSubscripti
 
         // use actual client id used to create connection to lookup connection
         // context
-        final String connectionInfoClientId = protocol.getClientId();
+        String connectionInfoClientId = protocol.getClientId();
+        // for zero-byte client ids we used connection id
+        if (connectionInfoClientId == null || connectionInfoClientId.isEmpty()) {
+            connectionInfoClientId = protocol.getConnectionId().toString();
+        }
         final ConnectionContext connectionContext = regionBroker.getConnectionContext(connectionInfoClientId);
 
         // get all matching Topics

http://git-wip-us.apache.org/repos/asf/activemq/blob/7948d690/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
----------------------------------------------------------------------
diff --git a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
index c9f106d..3bb8758 100644
--- a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
+++ b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
@@ -967,6 +967,29 @@ public class MQTTTest extends MQTTTestSupport {
     }
 
     @Test(timeout = 60 * 1000)
+    public void testNoClientId() throws Exception {
+        final MQTT mqtt = createMQTTConnection("", true);
+        final BlockingConnection connection = mqtt.blockingConnection();
+        connection.connect();
+        Wait.waitFor(new Wait.Condition() {
+            @Override
+            public boolean isSatisified() throws Exception {
+                return connection.isConnected();
+            }
+        });
+
+        connection.subscribe(new Topic[]{new Topic("TopicA", QoS.AT_LEAST_ONCE)});
+        connection.publish("TopicA", "test".getBytes(), QoS.AT_LEAST_ONCE, true);
+        Message message = connection.receive(3, TimeUnit.SECONDS);
+        assertNotNull(message);
+        Thread.sleep(2000);
+        connection.subscribe(new Topic[]{new Topic("TopicA", QoS.AT_LEAST_ONCE)});
+        //TODO fix audit problem for retained messages
+        //message = connection.receive(3, TimeUnit.SECONDS);
+        //assertNotNull(message);
+    }
+
+    @Test(timeout = 60 * 1000)
     public void testCleanSession() throws Exception {
         final String CLIENTID = "cleansession";
         final MQTT mqttNotClean = createMQTTConnection(CLIENTID, false);


Mime
View raw message