activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject activemq git commit: AMQ-5801: add error condition hint via the info map to signal the container-id was the invalid field
Date Wed, 27 May 2015 17:10:50 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 5e7b70f11 -> 138e52b08


AMQ-5801: add error condition hint via the info map to signal the container-id was the invalid
field


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

Branch: refs/heads/master
Commit: 138e52b08c2f49b730817932a6e63f2a135854f1
Parents: 5e7b70f
Author: Robert Gemmell <robbie@apache.org>
Authored: Wed May 27 18:08:40 2015 +0100
Committer: Robert Gemmell <robbie@apache.org>
Committed: Wed May 27 18:09:45 2015 +0100

----------------------------------------------------------------------
 .../activemq/transport/amqp/AmqpSupport.java    |  4 ++++
 .../transport/amqp/protocol/AmqpConnection.java | 10 +++++++-
 .../amqp/interop/AmqpConnectionsTest.java       | 24 ++++++++++++++++++--
 3 files changed, 35 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/138e52b0/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java
b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java
index 1c3d587..0579fcf 100644
--- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java
+++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java
@@ -46,6 +46,10 @@ public class AmqpSupport {
     public static final Symbol TEMP_TOPIC_CAPABILITY = Symbol.valueOf("temporary-topic");
 
     // Symbols used to announce connection information to remote peer.
+    public static final Symbol INVALID_FIELD = Symbol.valueOf("invalid-field");
+    public static final Symbol CONTAINER_ID = Symbol.valueOf("container-id");
+
+    // Symbols used to announce connection information to remote peer.
     public static final Symbol ANONYMOUS_RELAY = Symbol.valueOf("ANONYMOUS-RELAY");
     public static final Symbol QUEUE_PREFIX = Symbol.valueOf("queue-prefix");
     public static final Symbol TOPIC_PREFIX = Symbol.valueOf("topic-prefix");

http://git-wip-us.apache.org/repos/asf/activemq/blob/138e52b0/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java
b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java
index 711156a..962d48f 100644
--- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java
+++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java
@@ -18,6 +18,8 @@ package org.apache.activemq.transport.amqp.protocol;
 
 import static org.apache.activemq.transport.amqp.AmqpSupport.ANONYMOUS_RELAY;
 import static org.apache.activemq.transport.amqp.AmqpSupport.CONNECTION_OPEN_FAILED;
+import static org.apache.activemq.transport.amqp.AmqpSupport.CONTAINER_ID;
+import static org.apache.activemq.transport.amqp.AmqpSupport.INVALID_FIELD;
 import static org.apache.activemq.transport.amqp.AmqpSupport.QUEUE_PREFIX;
 import static org.apache.activemq.transport.amqp.AmqpSupport.TEMP_QUEUE_CAPABILITY;
 import static org.apache.activemq.transport.amqp.AmqpSupport.TEMP_TOPIC_CAPABILITY;
@@ -434,7 +436,13 @@ public class AmqpConnection implements AmqpProtocolConverter {
                         if (exception instanceof SecurityException) {
                             protonConnection.setCondition(new ErrorCondition(AmqpError.UNAUTHORIZED_ACCESS,
exception.getMessage()));
                         } else if (exception instanceof InvalidClientIDException) {
-                            protonConnection.setCondition(new ErrorCondition(AmqpError.INVALID_FIELD,
exception.getMessage()));
+                            ErrorCondition condition = new ErrorCondition(AmqpError.INVALID_FIELD,
exception.getMessage());
+
+                            Map<Symbol, Object> infoMap = new HashMap<Symbol, Object>
();
+                            infoMap.put(INVALID_FIELD, CONTAINER_ID);
+                            condition.setInfo(infoMap);
+
+                            protonConnection.setCondition(condition);
                         } else {
                             protonConnection.setCondition(new ErrorCondition(AmqpError.ILLEGAL_STATE,
exception.getMessage()));
                         }

http://git-wip-us.apache.org/repos/asf/activemq/blob/138e52b0/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java
index dfe3a4b..783db65 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull;
 
 import java.util.Map;
 
+import org.apache.activemq.transport.amqp.AmqpSupport;
 import org.apache.activemq.transport.amqp.client.AmqpClient;
 import org.apache.activemq.transport.amqp.client.AmqpClientTestSupport;
 import org.apache.activemq.transport.amqp.client.AmqpConnection;
@@ -145,11 +146,30 @@ public class AmqpConnectionsTest extends AmqpClientTestSupport {
             public void inspectClosedResource(Connection connection) {
                 ErrorCondition remoteError = connection.getRemoteCondition();
                 if (remoteError == null) {
-                    markAsInvalid("Broker dd not add error condition for duplicate client
ID");
+                    markAsInvalid("Broker did not add error condition for duplicate client
ID");
                 }
 
                 if (!remoteError.getCondition().equals(AmqpError.INVALID_FIELD)) {
-                    markAsInvalid("Broker dd not set condition to " + AmqpError.INVALID_FIELD);
+                    markAsInvalid("Broker did not set condition to " + AmqpError.INVALID_FIELD);
+                }
+
+                if (!remoteError.getCondition().equals(AmqpError.INVALID_FIELD)) {
+                    markAsInvalid("Broker did not set condition to " + AmqpError.INVALID_FIELD);
+                }
+
+                // Validate the info map contains a hint that the container/client id was
the problem
+                Map<?, ?> infoMap = remoteError.getInfo();
+                if(infoMap == null) {
+                    markAsInvalid("Broker did not set an info map on condition");
+                }
+
+                if(!infoMap.containsKey(AmqpSupport.INVALID_FIELD)) {
+                    markAsInvalid("Info map does not contain expected key");
+                }
+
+                Object value = infoMap.get(AmqpSupport.INVALID_FIELD);
+                if(!AmqpSupport.CONTAINER_ID.equals(value)) {
+                    markAsInvalid("Info map does not contain expected value: " + value);
                 }
             }
         });


Mime
View raw message