diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java index 0833fd81ba..5b80fcb5b3 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java @@ -616,8 +616,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener { props.putSimpleStringProperty(ManagementHelper.HDR_SESSION_NAME, SimpleString.toSimpleString(name)); - if (filterString != null) { - props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, filterString); + if (filter != null) { + props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, filter.getFilterString()); } if (remotingConnection.getClientID() != null) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/NotificationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/NotificationTest.java index 04be9b2845..02b998a0ca 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/NotificationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/NotificationTest.java @@ -188,11 +188,36 @@ public class NotificationTest extends ActiveMQTestBase { Assert.assertTrue(notifications[0].getTimestamp() >= start); Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start); Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP)); + Assert.assertNull(notifications[0].getSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING)); consumer.close(); session.deleteQueue(queue); } + @Test + public void testConsumerCreatedWithEmptyFilterString() throws Exception { + + SimpleString queue = RandomUtil.randomSimpleString(); + SimpleString address = RandomUtil.randomSimpleString(); + SimpleString filter = SimpleString.toSimpleString(""); + boolean durable = RandomUtil.randomBoolean(); + + try ( + ClientSessionFactory sf = createSessionFactory(locator); + ClientSession clientSession = sf.createSession("myUser", "myPassword", false, true, true, locator.isPreAcknowledge(), locator.getAckBatchSize()); + ) { + clientSession.start(); + session.createQueue(new QueueConfiguration(queue).setAddress(address).setDurable(durable)); + NotificationTest.flush(notifConsumer); + try (ClientConsumer ignored = clientSession.createConsumer(queue, filter)) { + ClientMessage[] notifications = NotificationTest.consumeMessages(1, notifConsumer); + Assert.assertNull(notifications[0].getSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING)); + } + } finally { + session.deleteQueue(queue); + } + } + @Test public void testSuppressSessionNotifications() throws Exception { server.getConfiguration().setSuppressSessionNotifications(false);