You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2017/03/08 15:36:49 UTC

svn commit: r1785989 - in /qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client: AMQAnyDestination.java AMQDestination.java AMQSession_0_10.java AMQTopic.java

Author: kwall
Date: Wed Mar  8 15:36:49 2017
New Revision: 1785989

URL: http://svn.apache.org/viewvc?rev=1785989&view=rev
Log:
QPID-7692: [Java Client] Allow routingKey/subject to be null in addresses

Modified:
    qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
    qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQDestination.java
    qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
    qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQTopic.java

Modified: qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
URL: http://svn.apache.org/viewvc/qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java?rev=1785989&r1=1785988&r2=1785989&view=diff
==============================================================================
--- qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java (original)
+++ qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java Wed Mar  8 15:36:49 2017
@@ -77,6 +77,7 @@ public class AMQAnyDestination extends A
         return getAMQQueueName() == null;
     }
 
+    @Override
     public String getTopicName() throws JMSException
     {
         if (getRoutingKey() != null)

Modified: qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQDestination.java
URL: http://svn.apache.org/viewvc/qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQDestination.java?rev=1785989&r1=1785988&r2=1785989&view=diff
==============================================================================
--- qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQDestination.java (original)
+++ qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQDestination.java Wed Mar  8 15:36:49 2017
@@ -372,12 +372,6 @@ public abstract class AMQDestination imp
     protected AMQDestination(String exchangeName, String exchangeClass, String routingKey, boolean isExclusive,
                              boolean isAutoDelete, String queueName, boolean isDurable, String[] bindingKeys, boolean browseOnly)
     {
-        if ( (ExchangeDefaults.DIRECT_EXCHANGE_CLASS.equals(exchangeClass) ||
-              ExchangeDefaults.TOPIC_EXCHANGE_CLASS.equals(exchangeClass))
-              && routingKey == null)
-        {
-            throw new IllegalArgumentException("routing/binding key  must not be null");
-        }
         if (exchangeName == null)
         {
             throw new IllegalArgumentException("Exchange name must not be null");
@@ -522,12 +516,16 @@ public abstract class AMQDestination imp
         {
             return _bindingKeys;
         }
-        else
+        else if (_routingKey != null)
         {
             // catering to the common use case where the
             //routingKey is the same as the bindingKey.
             return new String[]{_routingKey};
         }
+        else
+        {
+            return new String[0];
+        }
     }
 
     public boolean isExclusive()
@@ -578,7 +576,12 @@ public abstract class AMQDestination imp
             sb.append("://");
             sb.append(_exchangeName);
 
-            sb.append("/"+_routingKey+"/");
+            sb.append("/");
+            if (_routingKey != null)
+            {
+                sb.append(_routingKey);
+            }
+            sb.append("/");
 
             if (_queueName != null)
             {
@@ -667,6 +670,7 @@ public abstract class AMQDestination imp
         return url;
     }
 
+    @Override
     public boolean equals(Object o)
     {
         if (this == o)
@@ -726,6 +730,7 @@ public abstract class AMQDestination imp
         return true;
     }
 
+    @Override
     public int hashCode()
     {
         int result;

Modified: qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
URL: http://svn.apache.org/viewvc/qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java?rev=1785989&r1=1785988&r2=1785989&view=diff
==============================================================================
--- qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java (original)
+++ qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java Wed Mar  8 15:36:49 2017
@@ -949,12 +949,12 @@ public class AMQSession_0_10 extends AMQ
                         // Generate the queue name if the destination indicates that a client generated name is to be used.
                         if (amqd.isNameRequired())
                         {
-                            String binddingKey = "";
+                            String bindingKey = "";
                             for(String key : amqd.getBindingKeys())
                             {
-                               binddingKey = binddingKey + "_" + key;
+                               bindingKey = bindingKey + "_" + key;
                             }
-                            amqd.setQueueName(binddingKey + "@"
+                            amqd.setQueueName(bindingKey + "@"
                                     + amqd.getExchangeName() + "_" + UUID.randomUUID());
                         }
                         return send0_10QueueDeclare(amqd, noLocal, nowait, passive);

Modified: qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQTopic.java
URL: http://svn.apache.org/viewvc/qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQTopic.java?rev=1785989&r1=1785988&r2=1785989&view=diff
==============================================================================
--- qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQTopic.java (original)
+++ qpid/qpid-jms-amqp-0-x/trunk/client/src/main/java/org/apache/qpid/client/AMQTopic.java Wed Mar  8 15:36:49 2017
@@ -150,6 +150,7 @@ public class AMQTopic extends AMQDestina
         return connection.getClientID() + ":" + subscriptionName;
     }
 
+    @Override
     public String getTopicName() throws JMSException
     {
         if (getRoutingKey() != null)
@@ -179,6 +180,7 @@ public class AMQTopic extends AMQDestina
         }
     }
 
+    @Override
     public String getRoutingKey()
     {
         if (super.getRoutingKey() != null)
@@ -191,17 +193,19 @@ public class AMQTopic extends AMQDestina
         }
         else
         {
-            setRoutingKey("");
+            setRoutingKey("");  // Side effect
             setSubject("");
             return super.getRoutingKey();
         }
     }
 
+    @Override
     public boolean isNameRequired()
     {
         return !isDurable();
     }
 
+    @Override
     public boolean equals(Object o)
     {
         if (getDestSyntax() == DestSyntax.ADDR)
@@ -216,6 +220,7 @@ public class AMQTopic extends AMQDestina
         }
     }
 
+    @Override
     public int hashCode()
     {
         if (getDestSyntax() == DestSyntax.ADDR)



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org