activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: https://issues.apache.org/jira/browse/AMQ-5058
Date Mon, 17 Feb 2014 17:35:59 GMT
Repository: activemq
Updated Branches:
  refs/heads/trunk f42d56c1f -> b67978791


https://issues.apache.org/jira/browse/AMQ-5058

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

Branch: refs/heads/trunk
Commit: b679787917fe3cbf42f6dcd6bc8e9d7e853e5659
Parents: f42d56c
Author: Timothy Bish <tabish121@gmai.com>
Authored: Mon Feb 17 12:35:33 2014 -0500
Committer: Timothy Bish <tabish121@gmai.com>
Committed: Mon Feb 17 12:35:33 2014 -0500

----------------------------------------------------------------------
 .../transport/mqtt/MQTTProtocolConverter.java       | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/b6797879/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java
----------------------------------------------------------------------
diff --git a/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java
b/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java
index b816a32..e9fc9f7 100644
--- a/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java
+++ b/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java
@@ -187,7 +187,7 @@ public class MQTTProtocolConverter {
     void onMQTTConnect(final CONNECT connect) throws MQTTProtocolException {
 
         if (connected.get()) {
-            throw new MQTTProtocolException("All ready connected.");
+            throw new MQTTProtocolException("Already connected.");
         }
         this.connect = connect;
 
@@ -211,6 +211,18 @@ public class MQTTProtocolConverter {
         if (clientId != null && !clientId.isEmpty()) {
             connectionInfo.setClientId(clientId);
         } else {
+            // Clean Session MUST be set for 0 length Client Id
+            if (!connect.cleanSession()) {
+                CONNACK ack = new CONNACK();
+                ack.code(CONNACK.Code.CONNECTION_REFUSED_IDENTIFIER_REJECTED);
+                try {
+                    getMQTTTransport().sendToMQTT(ack.encode());
+                    getMQTTTransport().onException(IOExceptionSupport.create("Invalid Client
ID", null));
+                } catch (IOException e) {
+                    getMQTTTransport().onException(IOExceptionSupport.create(e));
+                }
+                return;
+            }
             connectionInfo.setClientId("" + connectionInfo.getConnectionId().toString());
         }
 
@@ -249,6 +261,7 @@ public class MQTTProtocolConverter {
                             ack.code(CONNACK.Code.CONNECTION_REFUSED_BAD_USERNAME_OR_PASSWORD);
                             getMQTTTransport().sendToMQTT(ack.encode());
                             getMQTTTransport().onException(IOExceptionSupport.create(exception));
+                            return;
                         }
 
                         CONNACK ack = new CONNACK();
@@ -289,7 +302,6 @@ public class MQTTProtocolConverter {
 
     public void restoreDurableSubs(List<SubscriptionInfo> subs) {
         try {
-            SUBSCRIBE command = new SUBSCRIBE();
             for (SubscriptionInfo sub : subs) {
                 String name = sub.getSubcriptionName();
                 String[] split = name.split(":", 2);


Mime
View raw message