ARTEMIS-4387 Fix empty consumer filter string leak

This commit is contained in:
Šmucr Jan 2023-08-14 10:06:25 +02:00
parent 064018a3e9
commit 2f2dacdd34
2 changed files with 27 additions and 2 deletions

View File

@ -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) {

View File

@ -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);