diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2014-08-14 22:46:14 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2014-08-14 22:46:14 +0000 |
| commit | c8b64a9c6739c1015d3d99d6901d216f35a6a367 (patch) | |
| tree | 880f837bed8541b8223cb09fb3b7cd3929513a2b /qpid/java | |
| parent | 780215c0557e8388a000de1dd8de7b5d53715347 (diff) | |
| download | qpid-python-c8b64a9c6739c1015d3d99d6901d216f35a6a367.tar.gz | |
QPID-6001 : [Java Client] Prevent NPE when publishing using ADDR destination to Broker using AMQP 0-9-1 or lower
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1618077 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
3 files changed, 53 insertions, 24 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java index ef0d023fb2..dbbc300910 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java @@ -26,6 +26,14 @@ import static org.apache.qpid.configuration.ClientProperties.DEFAULT_FLOW_CONTRO import static org.apache.qpid.configuration.ClientProperties.QPID_FLOW_CONTROL_WAIT_FAILURE; import static org.apache.qpid.configuration.ClientProperties.QPID_FLOW_CONTROL_WAIT_NOTIFY_PERIOD; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +import javax.jms.Destination; +import javax.jms.JMSException; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,13 +60,6 @@ import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.protocol.AMQMethodEvent; import org.apache.qpid.transport.TransportException; -import javax.jms.Destination; -import javax.jms.JMSException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; - public class AMQSession_0_8 extends AMQSession<BasicMessageConsumer_0_8, BasicMessageProducer_0_8> { /** Used for debugging. */ @@ -736,14 +737,9 @@ public class AMQSession_0_8 extends AMQSession<BasicMessageConsumer_0_8, BasicMe boolean isConsumer, boolean noLocal) throws AMQException { - throwUnsupportedAddressingSyntax(); + throw new UnsupportedAddressSyntaxException(dest); } - void throwUnsupportedAddressingSyntax() - { - throw new UnsupportedOperationException("The new addressing based syntax is " - + "not supported for AMQP 0-8/0-9/0-9-1 versions"); - } protected void flushAcknowledgments() { diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java index ed517d38a7..b9bb03444f 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java @@ -20,6 +20,17 @@ */ package org.apache.qpid.client; +import java.nio.ByteBuffer; +import java.util.UUID; + +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.Queue; +import javax.jms.Topic; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.apache.qpid.AMQException; import org.apache.qpid.client.message.AMQMessageDelegate_0_8; import org.apache.qpid.client.message.AbstractJMSMessage; @@ -33,16 +44,6 @@ import org.apache.qpid.framing.ContentBody; import org.apache.qpid.framing.ContentHeaderBody; import org.apache.qpid.framing.ExchangeDeclareBody; import org.apache.qpid.framing.MethodRegistry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Queue; -import javax.jms.Topic; - -import java.nio.ByteBuffer; -import java.util.UUID; public class BasicMessageProducer_0_8 extends BasicMessageProducer { @@ -60,7 +61,7 @@ public class BasicMessageProducer_0_8 extends BasicMessageProducer if (destination.getDestSyntax() == AMQDestination.DestSyntax.ADDR) { - getSession().throwUnsupportedAddressingSyntax(); + throw new UnsupportedAddressSyntaxException(destination); } if(getSession().isDeclareExchanges()) diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/UnsupportedAddressSyntaxException.java b/qpid/java/client/src/main/java/org/apache/qpid/client/UnsupportedAddressSyntaxException.java new file mode 100644 index 0000000000..c65fd7c189 --- /dev/null +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/UnsupportedAddressSyntaxException.java @@ -0,0 +1,32 @@ +/* + * + * 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.apache.qpid.client; + +class UnsupportedAddressSyntaxException extends UnsupportedOperationException +{ + UnsupportedAddressSyntaxException(final AMQDestination dest) + { + super("The address '" + dest.toString() + "' uses the " + AMQDestination.DestSyntax.ADDR + " addressing syntax" + + " which is not supported for AMQP 0-8/0-9/0-9-1 connections. Use the " + AMQDestination.DestSyntax.BURL + + " syntax instead:\n" + + "\tBURL:<Exchange Class>://<Exchange Name>/[<Destination>]/[<Queue>][?<option>='<value>'[&<option>='<value>']]\n"); + } +} |
