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 2018/05/03 09:49:02 UTC

[2/3] qpid-jms-amqp-0-x git commit: QPID-8141: [JMS AMQP 0-x] Avoid repeated exchange.declare when publishing when BURL address is in-use.

QPID-8141: [JMS AMQP 0-x] Avoid repeated exchange.declare when publishing when BURL address is in-use.

Cherry picked from master 6a5ffcf484c5bfab4b0e8ca3453baf9a7ba0c1c0


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/commit/a387cf8b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/tree/a387cf8b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/diff/a387cf8b

Branch: refs/heads/6.3.x
Commit: a387cf8becbbbb6e3fcda152f35c22b7b5a0f483
Parents: 610148e
Author: Keith Wall <kw...@apache.org>
Authored: Wed May 2 22:32:30 2018 +0100
Committer: Keith Wall <kw...@apache.org>
Committed: Thu May 3 10:48:29 2018 +0100

----------------------------------------------------------------------
 .../java/org/apache/qpid/client/AMQSession.java | 40 ++++++++------------
 1 file changed, 16 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/blob/a387cf8b/client/src/main/java/org/apache/qpid/client/AMQSession.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/qpid/client/AMQSession.java b/client/src/main/java/org/apache/qpid/client/AMQSession.java
index cba764e..b5d4870 100644
--- a/client/src/main/java/org/apache/qpid/client/AMQSession.java
+++ b/client/src/main/java/org/apache/qpid/client/AMQSession.java
@@ -30,7 +30,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
+import java.util.Objects;
 import java.util.UUID;
 import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
@@ -150,8 +150,8 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic
      */
     protected final boolean DAEMON_DISPATCHER_THREAD = Boolean.getBoolean(ClientProperties.DAEMON_DISPATCHER);
 
-    private final Set<AMQDestination>
-            _resolvedDestinations = Collections.synchronizedSet(Collections.newSetFromMap(new WeakHashMap<AMQDestination, Boolean>()));
+    private final Map<AMQDestination, AMQDestination>
+            _resolvedDestinations = Collections.synchronizedMap(new WeakHashMap<AMQDestination, AMQDestination>());
 
     private final long _dispatcherShutdownTimeoutMs;
 
@@ -661,7 +661,7 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic
 
     void setResolved(final AMQDestination dest)
     {
-        _resolvedDestinations.add(dest);
+        _resolvedDestinations.put(dest, dest);
     }
 
     void setUnresolved(final AMQDestination dest)
@@ -676,30 +676,22 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic
 
     boolean isResolved(final AMQDestination dest)
     {
-        if (!_resolvedDestinations.contains(dest))
+        AMQDestination resolvedDest = _resolvedDestinations.get(dest);
+        if (resolvedDest == dest)
         {
-            return false;
-        }
-
-        if (dest.getAddressType() == AMQDestination.QUEUE_TYPE)
-        {
-            // verify legacy fields are set
-            return dest.getQueueName() != null
-                   && dest.getQueueName().equals(dest.getAddressName())
-                   && dest.getExchangeName() != null
-                   && dest.getExchangeClass() != null
-                   && dest.getRoutingKey() != null;
+            return true;
         }
-        else if (dest.getAddressType() == AMQDestination.TOPIC_TYPE)
+        else if (resolvedDest == null)
         {
-            // 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 false;
         }
-        return false;
+
+        // verify legacy fields are equal
+        return Objects.equals(dest.getQueueName(), resolvedDest.getQueueName()) &&
+               Objects.equals(dest.getExchangeName(), resolvedDest.getExchangeName()) &&
+               Objects.equals(dest.getExchangeClass(), resolvedDest.getExchangeClass()) &&
+               Objects.equals(dest.getRoutingKey(), resolvedDest.getRoutingKey()) &&
+               Objects.equals(dest.getSubject(), resolvedDest.getSubject());
     }
 
     public abstract int resolveAddressType(AMQDestination dest) throws QpidException;


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