ARTEMIS-1392 Fix NPE when FQQN queue does not exist during multicast subscribe
This commit is contained in:
parent
d414a1968b
commit
32ac370edc
|
@ -22,6 +22,8 @@ import java.util.Objects;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.PooledByteBufAllocator;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQSecurityException;
|
||||
|
@ -73,9 +75,6 @@ import org.apache.qpid.proton.engine.Link;
|
|||
import org.apache.qpid.proton.engine.Sender;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.PooledByteBufAllocator;
|
||||
|
||||
/**
|
||||
* TODO: Merge {@link ProtonServerSenderContext} and {@link org.apache.activemq.artemis.protocol.amqp.client.ProtonClientSenderContext} once we support 'global' link names. The split is a workaround for outgoing links
|
||||
*/
|
||||
|
@ -334,8 +333,11 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr
|
|||
}
|
||||
|
||||
if (queueNameToUse != null) {
|
||||
SimpleString matchingAnycastQueue = sessionSPI.getMatchingQueue(addressToUse, queueNameToUse, RoutingType.MULTICAST);
|
||||
queue = matchingAnycastQueue.toString();
|
||||
SimpleString matchingQueue = sessionSPI.getMatchingQueue(addressToUse, queueNameToUse, RoutingType.MULTICAST);
|
||||
if (matchingQueue == null) {
|
||||
throw new ActiveMQAMQPNotFoundException("Queue: '" + queueNameToUse + "' does not exist");
|
||||
}
|
||||
queue = matchingQueue.toString();
|
||||
}
|
||||
//if the address specifies a broker configured queue then we always use this, treat it as a queue
|
||||
if (queue != null) {
|
||||
|
|
|
@ -68,6 +68,27 @@ public class AmqpFullyQualifiedNameTest extends JMSClientTestSupport {
|
|||
server.getConfiguration().addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, new HashMap<String, Object>(), "netty", new HashMap<String, Object>()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFQQNTopicWhenQueueDoesNotExist() throws Exception {
|
||||
Exception e = null;
|
||||
String queueName = "testQueue";
|
||||
|
||||
Connection connection = createConnection(false);
|
||||
try {
|
||||
connection.setClientID("FQQNconn");
|
||||
connection.start();
|
||||
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
Topic topic = session.createTopic(multicastAddress.toString() + "::" + queueName);
|
||||
session.createConsumer(topic);
|
||||
} catch (InvalidDestinationException ide) {
|
||||
e = ide;
|
||||
} finally {
|
||||
connection.close();
|
||||
}
|
||||
assertNotNull(e);
|
||||
assertTrue(e.getMessage().contains("Queue: '" + queueName + "' does not exist"));
|
||||
}
|
||||
|
||||
@Test(timeout = 60000)
|
||||
//there isn't much use of FQQN for topics
|
||||
//however we can test query functionality
|
||||
|
@ -78,7 +99,7 @@ public class AmqpFullyQualifiedNameTest extends JMSClientTestSupport {
|
|||
connection.setClientID("FQQNconn");
|
||||
connection.start();
|
||||
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
Topic topic = session.createTopic(multicastAddress.toString());
|
||||
Topic topic = session.createTopic(multicastAddress.toString() + "::someaddress");
|
||||
|
||||
MessageConsumer consumer1 = session.createConsumer(topic);
|
||||
MessageConsumer consumer2 = session.createConsumer(topic);
|
||||
|
|
Loading…
Reference in New Issue