Repository: activemq-artemis Updated Branches: refs/heads/master 8a3155c0b -> c13a9764c
ARTEMIS-666 Fix AMQP error message on address not found Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/ab39e70d Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/ab39e70d Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/ab39e70d Branch: refs/heads/master Commit: ab39e70dc9b52f5e414cd14ca8329b5fa0934659 Parents: 8a3155c Author: Martyn Taylor <[email protected]> Authored: Wed Aug 3 13:27:45 2016 +0100 Committer: Martyn Taylor <[email protected]> Committed: Wed Aug 3 13:28:34 2016 +0100 ---------------------------------------------------------------------- .../server/ProtonServerReceiverContext.java | 8 ++++-- .../server/ProtonServerSenderContext.java | 4 +++ .../ActiveMQAMQPNotFoundException.java | 30 ++++++++++++++++++++ .../ActiveMQAMQPProtocolMessageBundle.java | 7 +++-- .../tests/integration/proton/ProtonTest.java | 19 +++++++++++++ 5 files changed, 63 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ab39e70d/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/server/ProtonServerReceiverContext.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/server/ProtonServerReceiverContext.java b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/server/ProtonServerReceiverContext.java index 7d39bb7..fba869c 100644 --- a/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/server/ProtonServerReceiverContext.java +++ b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/server/ProtonServerReceiverContext.java @@ -30,6 +30,7 @@ import org.proton.plug.context.AbstractProtonReceiverContext; import org.proton.plug.context.AbstractProtonSessionContext; import org.proton.plug.exceptions.ActiveMQAMQPException; import org.proton.plug.exceptions.ActiveMQAMQPInternalErrorException; +import org.proton.plug.exceptions.ActiveMQAMQPNotFoundException; import org.proton.plug.logger.ActiveMQAMQPProtocolMessageBundle; import static org.proton.plug.util.DeliveryUtil.readDelivery; @@ -85,15 +86,18 @@ public class ProtonServerReceiverContext extends AbstractProtonReceiverContext { if (address == null) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.targetAddressNotSet(); } + try { if (!sessionSPI.queueQuery(address)) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.addressDoesntExist(); } } + catch (ActiveMQAMQPNotFoundException e) { + throw e; + } catch (Exception e) { - throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.errorFindingTemporaryQueue(e.getMessage()); + throw new ActiveMQAMQPInternalErrorException(e.getMessage(), e); } - } } flow(maxCreditAllocation, minCreditRefresh); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ab39e70d/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/server/ProtonServerSenderContext.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/server/ProtonServerSenderContext.java b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/server/ProtonServerSenderContext.java index 40a4548..4ffb2df 100644 --- a/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/server/ProtonServerSenderContext.java +++ b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/server/ProtonServerSenderContext.java @@ -46,6 +46,7 @@ import org.proton.plug.context.AbstractProtonSessionContext; import org.proton.plug.context.ProtonPlugSender; import org.proton.plug.exceptions.ActiveMQAMQPException; import org.proton.plug.exceptions.ActiveMQAMQPInternalErrorException; +import org.proton.plug.exceptions.ActiveMQAMQPNotFoundException; import org.proton.plug.logger.ActiveMQAMQPProtocolMessageBundle; import static org.proton.plug.AmqpSupport.JMS_SELECTOR_FILTER_IDS; @@ -223,6 +224,9 @@ public class ProtonServerSenderContext extends AbstractProtonContextSender imple throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.sourceAddressDoesntExist(); } } + catch (ActiveMQAMQPNotFoundException e) { + throw e; + } catch (Exception e) { throw new ActiveMQAMQPInternalErrorException(e.getMessage(), e); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ab39e70d/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/exceptions/ActiveMQAMQPNotFoundException.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/exceptions/ActiveMQAMQPNotFoundException.java b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/exceptions/ActiveMQAMQPNotFoundException.java new file mode 100644 index 0000000..dc4c400 --- /dev/null +++ b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/exceptions/ActiveMQAMQPNotFoundException.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.proton.plug.exceptions; + +import org.apache.qpid.proton.amqp.transport.AmqpError; + +public class ActiveMQAMQPNotFoundException extends ActiveMQAMQPException { + + public ActiveMQAMQPNotFoundException(String message, Throwable e) { + super(AmqpError.NOT_FOUND, message, e); + } + + public ActiveMQAMQPNotFoundException(String message) { + super(AmqpError.NOT_FOUND, message); + } +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ab39e70d/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/logger/ActiveMQAMQPProtocolMessageBundle.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/logger/ActiveMQAMQPProtocolMessageBundle.java b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/logger/ActiveMQAMQPProtocolMessageBundle.java index da919ae..8817310 100644 --- a/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/logger/ActiveMQAMQPProtocolMessageBundle.java +++ b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/logger/ActiveMQAMQPProtocolMessageBundle.java @@ -22,6 +22,7 @@ import org.proton.plug.exceptions.ActiveMQAMQPInvalidFieldException; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageBundle; import org.jboss.logging.Messages; +import org.proton.plug.exceptions.ActiveMQAMQPNotFoundException; /** * Logger Code 11 @@ -44,10 +45,10 @@ public interface ActiveMQAMQPProtocolMessageBundle { ActiveMQAMQPInternalErrorException errorCreatingTemporaryQueue(String message); @Message(id = 219002, value = "target address does not exist") - ActiveMQAMQPIllegalStateException addressDoesntExist(); + ActiveMQAMQPNotFoundException addressDoesntExist(); @Message(id = 219003, value = "error finding temporary queue, {0}", format = Message.Format.MESSAGE_FORMAT) - ActiveMQAMQPInternalErrorException errorFindingTemporaryQueue(String message); + ActiveMQAMQPNotFoundException errorFindingTemporaryQueue(String message); @Message(id = 219005, value = "error creating consumer, {0}", format = Message.Format.MESSAGE_FORMAT) ActiveMQAMQPInternalErrorException errorCreatingConsumer(String message); @@ -62,7 +63,7 @@ public interface ActiveMQAMQPProtocolMessageBundle { ActiveMQAMQPIllegalStateException errorCancellingMessage(String messageID, String message); @Message(id = 219010, value = "source address does not exist") - ActiveMQAMQPInvalidFieldException sourceAddressDoesntExist(); + ActiveMQAMQPNotFoundException sourceAddressDoesntExist(); @Message(id = 219011, value = "source address not set") ActiveMQAMQPInvalidFieldException sourceAddressNotSet(); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ab39e70d/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java ---------------------------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java index c479443..b170f82 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java @@ -527,6 +527,25 @@ public class ProtonTest extends ActiveMQTestBase { } @Test + public void testLinkDetatchErrorIsCorrectWhenQueueDoesNotExists() throws Exception { + AmqpClient client = new AmqpClient(new URI(tcpAmqpConnectionUri), userName, password); + AmqpConnection amqpConnection = client.connect(); + AmqpSession session = amqpConnection.createSession(); + + Exception expectedException = null; + try { + session.createSender("AnAddressThatDoesNotExist"); + } + catch (Exception e) { + expectedException = e; + } + + assertNotNull(expectedException); + assertTrue(expectedException.getMessage().contains("amqp:not-found")); + assertTrue(expectedException.getMessage().contains("target address does not exist")); + } + + @Test public void testReplyTo() throws Throwable { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
