ARTEMIS-3394 ClassCastException when queue & divert have same name
This commit is contained in:
parent
5ebaebdfa3
commit
55533ae099
|
@ -501,4 +501,7 @@ public interface ActiveMQMessageBundle {
|
|||
|
||||
@Message(id = 229234, value = "Invalid slow consumer threshold measurement unit {0}", format = Message.Format.MESSAGE_FORMAT)
|
||||
IllegalArgumentException invalidSlowConsumerThresholdMeasurementUnit(String val);
|
||||
|
||||
@Message(id = 229235, value = "Incompatible binding with name {0} already exists: {1}", format = Message.Format.MESSAGE_FORMAT)
|
||||
ActiveMQIllegalStateException bindingAlreadyExists(String name, String binding);
|
||||
}
|
||||
|
|
|
@ -3742,12 +3742,16 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
throw ActiveMQMessageBundle.BUNDLE.invalidQueueName(queueConfiguration.getName());
|
||||
}
|
||||
|
||||
final QueueBinding binding = (QueueBinding) postOffice.getBinding(queueConfiguration.getName());
|
||||
if (binding != null) {
|
||||
final Binding rawBinding = postOffice.getBinding(queueConfiguration.getName());
|
||||
if (rawBinding != null) {
|
||||
if (rawBinding.getType() != BindingType.LOCAL_QUEUE) {
|
||||
throw ActiveMQMessageBundle.BUNDLE.bindingAlreadyExists(queueConfiguration.getName().toString(), rawBinding.toManagementString());
|
||||
}
|
||||
final QueueBinding queueBinding = (QueueBinding) rawBinding;
|
||||
if (ignoreIfExists) {
|
||||
return binding.getQueue();
|
||||
return queueBinding.getQueue();
|
||||
} else {
|
||||
throw ActiveMQMessageBundle.BUNDLE.queueAlreadyExists(queueConfiguration.getName(), binding.getAddress());
|
||||
throw ActiveMQMessageBundle.BUNDLE.queueAlreadyExists(queueConfiguration.getName(), queueBinding.getAddress());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException;
|
||||
import org.apache.activemq.artemis.api.core.Message;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.QueueConfiguration;
|
||||
|
@ -57,6 +58,7 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
|||
import org.apache.activemq.artemis.core.settings.impl.DeletionPolicy;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.tests.util.CFUtil;
|
||||
import org.apache.activemq.artemis.tests.util.RandomUtil;
|
||||
import org.apache.activemq.command.ActiveMQTopic;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -179,6 +181,27 @@ public class DivertTest extends ActiveMQTestBase {
|
|||
Assert.assertNull(consumer2.receiveImmediate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDivertAndQueueWithSameName() throws Exception {
|
||||
final String name = RandomUtil.randomString();
|
||||
|
||||
ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(createDefaultInVMConfig()
|
||||
.addDivertConfiguration(new DivertConfiguration()
|
||||
.setName(name)
|
||||
.setRoutingName(RandomUtil.randomString())
|
||||
.setAddress(RandomUtil.randomString())
|
||||
.setForwardingAddress(RandomUtil.randomString())), false));
|
||||
|
||||
server.start();
|
||||
|
||||
try {
|
||||
server.createQueue(new QueueConfiguration(name));
|
||||
fail();
|
||||
} catch (ActiveMQIllegalStateException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCrossProtocol() throws Exception {
|
||||
final String testForConvert = "testConvert";
|
||||
|
|
Loading…
Reference in New Issue