Revert "QPID-8141: [JMS AMQP 0-x] Return resolved destination from Session#createQueu...
authorKeith Wall <kwall@apache.org>
Wed, 2 May 2018 13:03:11 +0000 (14:03 +0100)
committerKeith Wall <kwall@apache.org>
Wed, 2 May 2018 13:03:11 +0000 (14:03 +0100)
This reverts commit e6657e12d7d99956a08d58181c7dd57e9521eb24.

client/src/main/java/org/apache/qpid/client/AMQSession.java

index 8d10dd9..cba764e 100644 (file)
@@ -676,39 +676,32 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic
 
     boolean isResolved(final AMQDestination dest)
     {
-        return _resolvedDestinations.contains(dest);
-    }
-
-    private <T extends AMQDestination> T getResolvedOfSameClassOrRemoveResolved(final T destination, Class<T> destinationClass)
-    {
-        if (isResolved(destination))
+        if (!_resolvedDestinations.contains(dest))
         {
-            AMQDestination resolved = getResolved(destination);
-            if (resolved != null && destinationClass.isInstance(resolved))
-            {
-                return (T) resolved;
-            }
-            else
-            {
-                setUnresolved(destination);
-            }
+            return false;
         }
-        return destination;
-    }
 
-    private AMQDestination getResolved(AMQDestination destination)
-    {
-        for(AMQDestination resolved : _resolvedDestinations)
+        if (dest.getAddressType() == AMQDestination.QUEUE_TYPE)
         {
-            if (resolved.equals(destination))
-            {
-                return resolved;
-            }
+            // verify legacy fields are set
+            return dest.getQueueName() != null
+                   && dest.getQueueName().equals(dest.getAddressName())
+                   && dest.getExchangeName() != null
+                   && dest.getExchangeClass() != null
+                   && dest.getRoutingKey() != null;
+        }
+        else if (dest.getAddressType() == AMQDestination.TOPIC_TYPE)
+        {
+            // verify legacy fields are set
+            return dest.getExchangeName() != null
+                   && dest.getExchangeName().equals(dest.getAddressName())
+                   && dest.getExchangeClass() != null
+                   && (dest.getSubject() == null
+                        || (dest.getSubject() != null && dest.getSubject().equals(dest.getRoutingKey())));
         }
-        return null;
+        return false;
     }
 
-
     public abstract int resolveAddressType(AMQDestination dest) throws QpidException;
 
     protected abstract void acknowledgeImpl() throws JMSException;
@@ -1343,13 +1336,14 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic
                 }
                 else
                 {
-                    return getResolvedOfSameClassOrRemoveResolved(new AMQQueue(queueName), AMQQueue.class);
+                    AMQQueue queue = new AMQQueue(queueName);
+                    return queue;
 
                 }
             }
             else
             {
-                return getResolvedOfSameClassOrRemoveResolved(new AMQQueue(queueName), AMQQueue.class);
+                return new AMQQueue(queueName);
             }
         }
         catch (URISyntaxException urlse)
@@ -1647,13 +1641,12 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic
                 }
                 else
                 {
-                    AMQTopic topic = new AMQTopic("ADDR:" + getDefaultTopicExchangeName() + "/" + topicName);
-                    return getResolvedOfSameClassOrRemoveResolved(topic, AMQTopic.class);
+                    return new AMQTopic("ADDR:" + getDefaultTopicExchangeName() + "/" + topicName);
                 }
             }
             else
             {
-                return getResolvedOfSameClassOrRemoveResolved(new AMQTopic(topicName), AMQTopic.class);
+                return new AMQTopic(topicName);
             }
 
         }