Repository: activemq-artemis
Updated Branches:
  refs/heads/2.6.x 64568efca -> 4e03b4029


ARTEMIS-2072 refactor logic to fix tests

(cherry picked from commit 24fa0f920347f49270d1630b86b8b01987e66b92)


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

Branch: refs/heads/2.6.x
Commit: 4e03b4029b99068c274455512d53c29e421468d5
Parents: 64568ef
Author: Justin Bertram <[email protected]>
Authored: Thu Sep 6 12:52:25 2018 -0500
Committer: Clebert Suconic <[email protected]>
Committed: Thu Sep 6 18:06:52 2018 -0400

----------------------------------------------------------------------
 .../amqp/broker/AMQPSessionCallback.java        | 49 +++++++++++---------
 1 file changed, 28 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4e03b402/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
----------------------------------------------------------------------
diff --git 
a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
 
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
index b32a4c7..6b163ae 100644
--- 
a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
+++ 
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
@@ -45,6 +45,7 @@ import org.apache.activemq.artemis.core.server.ServerProducer;
 import org.apache.activemq.artemis.core.server.ServerSession;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl;
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import 
org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException;
 import 
org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException;
@@ -306,33 +307,39 @@ public class AMQPSessionCallback implements 
SessionCallback {
 
 
    public boolean checkAddressAndAutocreateIfPossible(SimpleString address, 
RoutingType routingType) throws Exception {
-      AddressInfo addressInfo = manager.getServer().getAddressInfo(address);
-
-      // if the address exists go ahead and return
-      if (addressInfo != null) {
-         return true;
-      }
-
-      // if the address and/or queue don't exist then create them if possible
-      if (routingType == RoutingType.MULTICAST && addressInfo == null) {
-         if 
(manager.getServer().getAddressSettingsRepository().getMatch(address.toString()).isAutoCreateAddresses())
 {
-            try {
-               serverSession.createAddress(address, routingType, true);
-            } catch (ActiveMQAddressExistsException e) {
-               // The address may have been created by another thread in the 
mean time.  Catch and do nothing.
+      boolean result = false;
+      SimpleString unPrefixedAddress = serverSession.removePrefix(address);
+      AddressSettings addressSettings = 
manager.getServer().getAddressSettingsRepository().getMatch(unPrefixedAddress.toString());
+
+      if (routingType == RoutingType.MULTICAST) {
+         if (manager.getServer().getAddressInfo(unPrefixedAddress) == null) {
+            if (addressSettings.isAutoCreateAddresses()) {
+               try {
+                  serverSession.createAddress(address, routingType, true);
+               } catch (ActiveMQAddressExistsException e) {
+                  // The address may have been created by another thread in 
the mean time.  Catch and do nothing.
+               }
+               result = true;
             }
+         } else {
+            result = true;
          }
-      } else if (routingType == RoutingType.ANYCAST && 
manager.getServer().locateQueue(address) == null) {
-         if 
(manager.getServer().getAddressSettingsRepository().getMatch(address.toString()).isAutoCreateQueues())
 {
-            try {
-               serverSession.createQueue(address, address, routingType, null, 
false, true, true);
-            } catch (ActiveMQQueueExistsException e) {
-               // The queue may have been created by another thread in the 
mean time.  Catch and do nothing.
+      } else if (routingType == RoutingType.ANYCAST) {
+         if (manager.getServer().locateQueue(unPrefixedAddress) == null) {
+            if (addressSettings.isAutoCreateQueues()) {
+               try {
+                  serverSession.createQueue(address, address, routingType, 
null, false, true, true);
+               } catch (ActiveMQQueueExistsException e) {
+                  // The queue may have been created by another thread in the 
mean time.  Catch and do nothing.
+               }
+               result = true;
             }
+         } else {
+            result = true;
          }
       }
 
-      return manager.getServer().getAddressInfo(address) != null;
+      return result;
    }
 
 

Reply via email to