This is an automated email from the ASF dual-hosted git repository.
jbertram pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new cdcbfb2 ARTEMIS-3627 - support 25k type postfix, same feature as xml
config, for long values
new 4692603 This closes #3959
cdcbfb2 is described below
commit cdcbfb2ae0be38078f52e806e842315408bc48d9
Author: gtully <[email protected]>
AuthorDate: Wed Feb 16 17:56:57 2022 +0000
ARTEMIS-3627 - support 25k type postfix, same feature as xml config, for
long values
---
.../artemis/core/config/impl/ConfigurationImpl.java | 9 +++++++++
.../artemis/core/config/impl/ConfigurationImplTest.java | 13 +++++++++++++
2 files changed, 22 insertions(+)
diff --git
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
index ff7d511..7bac741 100644
---
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
+++
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
@@ -96,6 +96,7 @@ import
org.apache.activemq.artemis.core.server.plugin.ActiveMQServerResourcePlug
import
org.apache.activemq.artemis.core.server.plugin.ActiveMQServerSessionPlugin;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings;
+import org.apache.activemq.artemis.utils.ByteUtil;
import org.apache.activemq.artemis.utils.Env;
import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader;
import org.apache.activemq.artemis.utils.critical.CriticalAnalyzerPolicy;
@@ -507,6 +508,14 @@ public class ConfigurationImpl implements Configuration,
Serializable {
return (T) SimpleString.toSimpleString(value.toString());
}
}, SimpleString.class);
+ // support 25K or 25m etc like xml config
+ beanUtils.getConvertUtils().register(new Converter() {
+ @Override
+ public <T> T convert(Class<T> type, Object value) {
+ return (T) (Long) ByteUtil.convertTextBytes(value.toString());
+ }
+ }, Long.TYPE);
+
BeanSupport.customise(beanUtils);
beanUtils.populate(this, beanProperties);
diff --git
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
index 317d6dd..fae3531 100644
---
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
+++
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
@@ -690,6 +690,19 @@ public class ConfigurationImplTest extends
ActiveMQTestBase {
}
@Test
+ public void testValuePostFixModifier() throws Throwable {
+ ConfigurationImpl configuration = new ConfigurationImpl();
+
+ Properties properties = new Properties();
+
+ properties.put("globalMaxSize", "25K");
+
+ configuration.parsePrefixedProperties(properties, null);
+
+ Assert.assertEquals(25 * 1024, configuration.getGlobalMaxSize());
+ }
+
+ @Test
public void testNameWithDotsSurroundWithDollarDollar() throws Throwable {
ConfigurationImpl configuration = new ConfigurationImpl();