From 3db540c61b39043c50233c2a716398fe914c278d Mon Sep 17 00:00:00 2001 From: Justin Bertram Date: Thu, 15 Jun 2023 12:48:29 -0500 Subject: [PATCH] ARTEMIS-4315 incorrect validation for page-limit settings --- .../core/deployers/impl/FileConfigurationParser.java | 6 +++--- .../core/config/impl/FileConfigurationParserTest.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java index cd2f6e6ed8..b7d28d29a5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java @@ -1301,11 +1301,11 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { addressSettings.setPageCacheMaxSize(XMLUtil.parseInt(child)); } else if (PAGE_LIMIT_BYTES_NODE_NAME.equalsIgnoreCase(name)) { long pageLimitBytes = ByteUtil.convertTextBytes(getTrimmedTextContent(child)); - Validators.MINUS_ONE_OR_POSITIVE_INT.validate(PAGE_LIMIT_BYTES_NODE_NAME, pageLimitBytes); + Validators.MINUS_ONE_OR_GT_ZERO.validate(PAGE_LIMIT_BYTES_NODE_NAME, pageLimitBytes); addressSettings.setPageLimitBytes(pageLimitBytes); } else if (PAGE_LIMIT_MESSAGES_NODE_NAME.equalsIgnoreCase(name)) { - long pageLimitMessages = ByteUtil.convertTextBytes(getTrimmedTextContent(child)); - Validators.MINUS_ONE_OR_POSITIVE_INT.validate(PAGE_LIMIT_MESSAGES_NODE_NAME, pageLimitMessages); + long pageLimitMessages = XMLUtil.parseLong(child); + Validators.MINUS_ONE_OR_GT_ZERO.validate(PAGE_LIMIT_MESSAGES_NODE_NAME, pageLimitMessages); addressSettings.setPageLimitMessages(pageLimitMessages); } else if (MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME.equalsIgnoreCase(name)) { addressSettings.setMessageCounterHistoryDayLimit(XMLUtil.parseInt(child)); diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java index f092466589..82cf009cf3 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java @@ -414,7 +414,7 @@ public class FileConfigurationParserTest extends ActiveMQTestBase { @Test public void testParsePageLimitSettings() throws Exception { - String configStr = "" + "\n" + "" + "\n" + "1k2k337FAIL33.\n" + "" + "\n" + "" + "\n"; + String configStr = "" + "\n" + "" + "\n" + "1k10G3221225472FAIL33.\n" + "" + "\n" + "" + "\n"; FileConfigurationParser parser = new FileConfigurationParser(); ByteArrayInputStream input = new ByteArrayInputStream(configStr.getBytes(StandardCharsets.UTF_8)); @@ -423,8 +423,8 @@ public class FileConfigurationParserTest extends ActiveMQTestBase { AddressSettings settings = configuration.getAddressSettings().get("foo"); Assert.assertEquals(1024, settings.getMaxReadPageBytes()); Assert.assertEquals(33, settings.getMaxReadPageMessages()); - Assert.assertEquals(2048L, settings.getPageLimitBytes().longValue()); - Assert.assertEquals(337L, settings.getPageLimitMessages().longValue()); + Assert.assertEquals(10L * 1024 * 1024 * 1024, settings.getPageLimitBytes().longValue()); + Assert.assertEquals(3L * 1024 * 1024 * 1024, settings.getPageLimitMessages().longValue()); Assert.assertEquals("FAIL", settings.getPageFullMessagePolicy().toString()); }