From 7b25cbb51da9310e7f4cd611c6bef949e50dd40a Mon Sep 17 00:00:00 2001 From: Justin Bertram Date: Thu, 10 Feb 2022 11:25:20 -0600 Subject: [PATCH] ARTEMIS-3677 add test, etc. --- .../core/message/impl/CoreMessage.java | 2 +- .../management/QueueControlTest.java | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java index 48ea5fdf46..4b4a2cff9d 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java @@ -1410,7 +1410,7 @@ public class CoreMessage extends RefCountMessage implements ICoreMessage { rc.put(CompositeDataConstants.TEXT_BODY, "[compressed]"); } else { SimpleString text = m.getReadOnlyBodyBuffer().readNullableSimpleString(); - rc.put(CompositeDataConstants.TEXT_BODY, text != null ? JsonUtil.truncate(text.toString(), valueSizeLimit) : ""); + rc.put(CompositeDataConstants.TEXT_BODY, JsonUtil.truncate(text != null ? text.toString() : text, valueSizeLimit)); } } else { rc.put(CompositeDataConstants.TEXT_BODY, "[large message]"); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java index aa7c897dfa..3ac730c5ee 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java @@ -3729,6 +3729,26 @@ public class QueueControlTest extends ManagementTestBase { session.deleteQueue(queue); } + @Test + public void testBrowseWithNullPropertyValue() throws Exception { + SimpleString address = RandomUtil.randomSimpleString(); + SimpleString queue = RandomUtil.randomSimpleString(); + + session.createQueue(new QueueConfiguration(queue).setAddress(address).setDurable(durable)); + + ClientProducer producer = session.createProducer(address); + ClientMessage m = session.createMessage(true); + m.putStringProperty(RandomUtil.randomString(), null); + producer.send(m); + producer.close(); + + QueueControl queueControl = createManagementControl(address, queue); + + assertEquals(1, queueControl.browse().length); + + session.deleteQueue(queue); + } + @Test public void testResetGroups() throws Exception { SimpleString address = RandomUtil.randomSimpleString();