From 55fbcfebf8460a415573565f6dc447a1e9092ecc Mon Sep 17 00:00:00 2001 From: Martyn Taylor Date: Thu, 15 Dec 2016 17:13:09 +0000 Subject: [PATCH] Do not autoDelete address if it was not autoCreated --- .../amqp/proton/ProtonServerSenderContext.java | 14 ++++++++++---- .../core/server/impl/ActiveMQServerImpl.java | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java index 52730e1eae..f6c7786703 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; +import org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException; import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.api.core.SimpleString; @@ -247,13 +248,18 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr boolean clientDefined = hasCapabilities(TOPIC, source) || hasCapabilities(QUEUE, source); if (clientDefined) { multicast = hasCapabilities(TOPIC, source); - AddressInfo addressInfo = sessionSPI.getAddress(addressToUse); - Set routingTypes = addressInfo.getRoutingTypes(); + AddressQueryResult addressQueryResult = sessionSPI.addressQuery(addressToUse.toString(), defaultRoutingType, true); + if (!addressQueryResult.isExists()) { + throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.sourceAddressDoesntExist(); + } + + Set routingTypes = addressQueryResult.getRoutingTypes(); + //if the client defines 1 routing type and the broker another then throw an exception if (multicast && !routingTypes.contains(RoutingType.MULTICAST)) { - throw new ActiveMQAMQPIllegalStateException("Address " + addressInfo.getName() + " is not configured for topic support"); + throw new ActiveMQAMQPIllegalStateException("Address " + addressToUse + " is not configured for topic support"); } else if (!multicast && !routingTypes.contains(RoutingType.ANYCAST)) { - throw new ActiveMQAMQPIllegalStateException("Address " + addressInfo.getName() + " is not configured for queue support"); + throw new ActiveMQAMQPIllegalStateException("Address " + addressToUse + " is not configured for queue support"); } } else { //if not we look up the address 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 f186614f76..76ba050007 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 @@ -1767,7 +1767,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { queue.deleteQueue(removeConsumers); - if (autoDeleteAddress && postOffice != null) { + if (autoDeleteAddress && postOffice != null && getAddressInfo(address).isAutoCreated()) { try { removeAddressInfo(address, session); } catch (ActiveMQDeleteAddressException e) {