activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-2072 refactor logic to fix tests
Date Thu, 06 Sep 2018 22:06:39 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 05ce7c6ec -> 0adee3c33


ARTEMIS-2072 refactor logic to fix tests


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

Branch: refs/heads/master
Commit: 24fa0f920347f49270d1630b86b8b01987e66b92
Parents: 05ce7c6
Author: Justin Bertram <jbertram@apache.org>
Authored: Thu Sep 6 12:52:25 2018 -0500
Committer: Justin Bertram <jbertram@apache.org>
Committed: Thu Sep 6 12:53:57 2018 -0500

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


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/24fa0f92/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;
    }
 
 


Mime
View raw message