activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martyntay...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-1456 use queue name when null address on createQueue
Date Tue, 17 Oct 2017 09:03:56 GMT
ARTEMIS-1456 use queue name when null address on createQueue


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

Branch: refs/heads/master
Commit: eee72a61d1d14ba7cfaaa417f040f8f7f8c81bc5
Parents: b7322b5
Author: Justin Bertram <jbertram@apache.org>
Authored: Mon Oct 16 16:33:54 2017 -0500
Committer: Martyn Taylor <mtaylor@redhat.com>
Committed: Tue Oct 17 10:03:33 2017 +0100

----------------------------------------------------------------------
 .../impl/ActiveMQServerControlImpl.java         |  4 ++--
 .../core/server/impl/ActiveMQServerImpl.java    | 23 ++++++++++----------
 .../management/ActiveMQServerControlTest.java   | 23 ++++++++++++++++++++
 3 files changed, 36 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/eee72a61/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
index 08facbf..03defb5 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
@@ -779,13 +779,13 @@ public class ActiveMQServerControlImpl extends AbstractControl implements
Active
 
    @Override
    public void createQueue(final String address, final String name, final String filterStr,
final boolean durable) throws Exception {
-      createQueue(address, name, filterStr, durable, server.getAddressSettingsRepository().getMatch(address).getDefaultQueueRoutingType().toString());
+      createQueue(address, name, filterStr, durable, server.getAddressSettingsRepository().getMatch(address
== null ? name : address).getDefaultQueueRoutingType().toString());
    }
 
 
    @Override
    public void createQueue(final String address, final String name, final String filterStr,
final boolean durable, final String routingType) throws Exception {
-      AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch(address);
+      AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch(address
== null ? name : address);
       createQueue(address, routingType, name, filterStr, durable, addressSettings.getDefaultMaxConsumers(),
addressSettings.isDefaultPurgeOnNoConsumers(), addressSettings.isAutoCreateAddresses());
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/eee72a61/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 198ed45..018e370 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -1655,7 +1655,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final SimpleString filterString,
                             final boolean durable,
                             final boolean temporary) throws Exception {
-      AddressSettings as = getAddressSettingsRepository().getMatch(address.toString());
+      AddressSettings as = getAddressSettingsRepository().getMatch(address == null ? queueName.toString()
: address.toString());
       return createQueue(address, routingType, queueName, filterString, durable, temporary,
as.getDefaultMaxConsumers(), as.isDefaultPurgeOnNoConsumers(), as.isAutoCreateAddresses());
    }
 
@@ -1667,7 +1667,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final SimpleString filterString,
                             final boolean durable,
                             final boolean temporary) throws Exception {
-      AddressSettings as = getAddressSettingsRepository().getMatch(address.toString());
+      AddressSettings as = getAddressSettingsRepository().getMatch(address == null ? queueName.toString()
: address.toString());
       return createQueue(address, routingType, queueName, filterString, user, durable, temporary,
false, as.getDefaultMaxConsumers(), as.isDefaultPurgeOnNoConsumers(), as.isAutoCreateAddresses());
    }
 
@@ -1706,7 +1706,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final SimpleString filterString,
                             final boolean durable,
                             final boolean temporary) throws Exception {
-      return createQueue(address, getAddressSettingsRepository().getMatch(address.toString()).getDefaultQueueRoutingType(),
queueName, filterString, durable, temporary);
+      return createQueue(address, getAddressSettingsRepository().getMatch(address == null
? queueName.toString() : address.toString()).getDefaultQueueRoutingType(), queueName, filterString,
durable, temporary);
    }
 
    @Override
@@ -1769,7 +1769,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final SimpleString filterString,
                             final boolean durable,
                             final boolean temporary) throws Exception {
-      return createQueue(address, getAddressSettingsRepository().getMatch(address.toString()).getDefaultQueueRoutingType(),
resourceName, filterString, durable, temporary);
+      return createQueue(address, getAddressSettingsRepository().getMatch(address == null
? resourceName.toString() : address.toString()).getDefaultQueueRoutingType(), resourceName,
filterString, durable, temporary);
    }
 
    @Deprecated
@@ -2710,18 +2710,17 @@ public class ActiveMQServerImpl implements ActiveMQServer {
       final long queueID = storageManager.generateID();
 
       final QueueConfig.Builder queueConfigBuilder;
-      if (address == null) {
-         queueConfigBuilder = QueueConfig.builderWith(queueID, queueName);
-      } else {
-         queueConfigBuilder = QueueConfig.builderWith(queueID, queueName, address);
-      }
 
-      AddressInfo info = postOffice.getAddressInfo(address);
+      final SimpleString addressToUse = address == null ? queueName : address;
+
+      queueConfigBuilder = QueueConfig.builderWith(queueID, queueName, addressToUse);
+
+      AddressInfo info = postOffice.getAddressInfo(addressToUse);
 
       if (autoCreateAddress) {
          RoutingType rt = (routingType == null ? ActiveMQDefaultConfiguration.getDefaultRoutingType()
: routingType);
          if (info == null) {
-            final AddressInfo addressInfo = new AddressInfo(address, rt);
+            final AddressInfo addressInfo = new AddressInfo(addressToUse, rt);
             addressInfo.setAutoCreated(true);
             addAddressInfo(addressInfo);
          } else if (!info.getRoutingTypes().contains(routingType)) {
@@ -2731,7 +2730,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
             updateAddressInfo(info.getName(), routingTypes);
          }
       } else if (info == null) {
-         throw ActiveMQMessageBundle.BUNDLE.addressDoesNotExist(address);
+         throw ActiveMQMessageBundle.BUNDLE.addressDoesNotExist(addressToUse);
       } else if (!info.getRoutingTypes().contains(routingType)) {
          throw ActiveMQMessageBundle.BUNDLE.invalidRoutingTypeForAddress(routingType, info.getName().toString(),
info.getRoutingTypes());
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/eee72a61/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
index 38b1682..e3725d8 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
@@ -207,6 +207,29 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
    }
 
    @Test
+   public void testCreateQueueWithNullAddress() throws Exception {
+      SimpleString address = RandomUtil.randomSimpleString();
+      SimpleString name = address;
+
+      ActiveMQServerControl serverControl = createManagementControl();
+
+      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
+      serverControl.createQueue(null, name.toString(), "ANYCAST");
+
+      checkResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(name, name, RoutingType.ANYCAST));
+      QueueControl queueControl = ManagementControlHelper.createQueueControl(address, name,
RoutingType.ANYCAST, mbeanServer);
+      Assert.assertEquals(address.toString(), queueControl.getAddress());
+      Assert.assertEquals(name.toString(), queueControl.getName());
+      Assert.assertNull(queueControl.getFilter());
+      Assert.assertEquals(true, queueControl.isDurable());
+      Assert.assertEquals(false, queueControl.isTemporary());
+
+      serverControl.destroyQueue(name.toString());
+
+      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
+   }
+
+   @Test
    public void testCreateAndDestroyQueue_2() throws Exception {
       SimpleString address = RandomUtil.randomSimpleString();
       SimpleString name = RandomUtil.randomSimpleString();


Mime
View raw message