ARTEMIS-4315 incorrect validation for page-limit settings

This commit is contained in:
Justin Bertram 2023-06-15 12:48:29 -05:00 committed by Robbie Gemmell
parent 2de12d211c
commit 3db540c61b
2 changed files with 6 additions and 6 deletions

View File

@ -1301,11 +1301,11 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
addressSettings.setPageCacheMaxSize(XMLUtil.parseInt(child)); addressSettings.setPageCacheMaxSize(XMLUtil.parseInt(child));
} else if (PAGE_LIMIT_BYTES_NODE_NAME.equalsIgnoreCase(name)) { } else if (PAGE_LIMIT_BYTES_NODE_NAME.equalsIgnoreCase(name)) {
long pageLimitBytes = ByteUtil.convertTextBytes(getTrimmedTextContent(child)); 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); addressSettings.setPageLimitBytes(pageLimitBytes);
} else if (PAGE_LIMIT_MESSAGES_NODE_NAME.equalsIgnoreCase(name)) { } else if (PAGE_LIMIT_MESSAGES_NODE_NAME.equalsIgnoreCase(name)) {
long pageLimitMessages = ByteUtil.convertTextBytes(getTrimmedTextContent(child)); long pageLimitMessages = XMLUtil.parseLong(child);
Validators.MINUS_ONE_OR_POSITIVE_INT.validate(PAGE_LIMIT_MESSAGES_NODE_NAME, pageLimitMessages); Validators.MINUS_ONE_OR_GT_ZERO.validate(PAGE_LIMIT_MESSAGES_NODE_NAME, pageLimitMessages);
addressSettings.setPageLimitMessages(pageLimitMessages); addressSettings.setPageLimitMessages(pageLimitMessages);
} else if (MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME.equalsIgnoreCase(name)) { } else if (MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setMessageCounterHistoryDayLimit(XMLUtil.parseInt(child)); addressSettings.setMessageCounterHistoryDayLimit(XMLUtil.parseInt(child));

View File

@ -414,7 +414,7 @@ public class FileConfigurationParserTest extends ActiveMQTestBase {
@Test @Test
public void testParsePageLimitSettings() throws Exception { public void testParsePageLimitSettings() throws Exception {
String configStr = "<configuration><address-settings>" + "\n" + "<address-setting match=\"foo\">" + "\n" + "<max-read-page-bytes>1k</max-read-page-bytes><page-limit-bytes>2k</page-limit-bytes><page-limit-messages>337</page-limit-messages><page-full-policy>FAIL</page-full-policy><max-read-page-messages>33</max-read-page-messages>.\n" + "</address-setting>" + "\n" + "</address-settings></configuration>" + "\n"; String configStr = "<configuration><address-settings>" + "\n" + "<address-setting match=\"foo\">" + "\n" + "<max-read-page-bytes>1k</max-read-page-bytes><page-limit-bytes>10G</page-limit-bytes><page-limit-messages>3221225472</page-limit-messages><page-full-policy>FAIL</page-full-policy><max-read-page-messages>33</max-read-page-messages>.\n" + "</address-setting>" + "\n" + "</address-settings></configuration>" + "\n";
FileConfigurationParser parser = new FileConfigurationParser(); FileConfigurationParser parser = new FileConfigurationParser();
ByteArrayInputStream input = new ByteArrayInputStream(configStr.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream input = new ByteArrayInputStream(configStr.getBytes(StandardCharsets.UTF_8));
@ -423,8 +423,8 @@ public class FileConfigurationParserTest extends ActiveMQTestBase {
AddressSettings settings = configuration.getAddressSettings().get("foo"); AddressSettings settings = configuration.getAddressSettings().get("foo");
Assert.assertEquals(1024, settings.getMaxReadPageBytes()); Assert.assertEquals(1024, settings.getMaxReadPageBytes());
Assert.assertEquals(33, settings.getMaxReadPageMessages()); Assert.assertEquals(33, settings.getMaxReadPageMessages());
Assert.assertEquals(2048L, settings.getPageLimitBytes().longValue()); Assert.assertEquals(10L * 1024 * 1024 * 1024, settings.getPageLimitBytes().longValue());
Assert.assertEquals(337L, settings.getPageLimitMessages().longValue()); Assert.assertEquals(3L * 1024 * 1024 * 1024, settings.getPageLimitMessages().longValue());
Assert.assertEquals("FAIL", settings.getPageFullMessagePolicy().toString()); Assert.assertEquals("FAIL", settings.getPageFullMessagePolicy().toString());
} }