ARTEMIS-3696 avoid null prop values on STOMP msgs

This commit is contained in:
Justin Bertram 2022-02-25 09:41:21 -06:00 committed by clebertsuconic
parent 2d16ec3305
commit c4ebccd94d
2 changed files with 25 additions and 4 deletions

View File

@ -47,10 +47,14 @@ public class StompUtils {
if (persistent != null) {
msg.setDurable(Boolean.parseBoolean(persistent));
}
msg.putObjectProperty(MessageUtil.CORRELATIONID_HEADER_NAME, headers.remove(Stomp.Headers.Send.CORRELATION_ID));
msg.putObjectProperty(MessageUtil.TYPE_HEADER_NAME, headers.remove(Stomp.Headers.Send.TYPE));
String correlationID = headers.remove(Stomp.Headers.Send.CORRELATION_ID);
if (correlationID != null) {
msg.putObjectProperty(MessageUtil.CORRELATIONID_HEADER_NAME, correlationID);
}
String type = headers.remove(Stomp.Headers.Send.TYPE);
if (type != null) {
msg.putObjectProperty(MessageUtil.TYPE_HEADER_NAME, type);
}
String groupID = headers.remove(MessageUtil.JMSXGROUPID);
if (groupID != null) {
msg.putStringProperty(Message.HDR_GROUP_ID, SimpleString.toSimpleString(groupID));

View File

@ -57,7 +57,9 @@ import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.jms.client.ActiveMQMessage;
import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
import org.apache.activemq.artemis.reader.MessageUtil;
import org.apache.activemq.artemis.tests.integration.mqtt.FuseMQTTClientProvider;
import org.apache.activemq.artemis.tests.integration.mqtt.MQTTClientProvider;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
@ -244,6 +246,21 @@ public class StompTest extends StompTestBase {
Assert.assertTrue(Math.abs(tnow - tmsg) < 1000);
}
@Test
public void testNullCorrelationIDandTypeProperties() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
conn.connect(defUser, defPass);
send(conn, getQueuePrefix() + getQueueName(), null, "Hello World");
TextMessage message = (TextMessage) consumer.receive(1000);
Assert.assertNotNull(message);
Assert.assertFalse(((ActiveMQMessage)message).getCoreMessage().getPropertyNames().contains(MessageUtil.CORRELATIONID_HEADER_NAME));
Assert.assertFalse(((ActiveMQMessage)message).getCoreMessage().getPropertyNames().contains(MessageUtil.TYPE_HEADER_NAME));
}
@Test
public void sendSTOMPReceiveMQTT() throws Exception {
// Set up MQTT Subscription