This is an automated email from the ASF dual-hosted git repository.
gtully 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 e164a5b ARTEMIS-3627 - fix regression in CriticalCrashTest -
statically configured converters were being lost on new custom bean utils
e164a5b is described below
commit e164a5b3b8874b9db45c556147fd6f64b4a4e63e
Author: gtully <[email protected]>
AuthorDate: Tue Jan 25 13:43:50 2022 +0000
ARTEMIS-3627 - fix regression in CriticalCrashTest - statically configured
converters were being lost on new custom bean utils
---
.../org/apache/activemq/artemis/utils/uri/BeanSupport.java | 11 ++++++++++-
.../activemq/artemis/core/config/impl/ConfigurationImpl.java | 4 ++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git
a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/BeanSupport.java
b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/BeanSupport.java
index cbacf01..ef4b39a 100644
---
a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/BeanSupport.java
+++
b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/BeanSupport.java
@@ -35,18 +35,27 @@ import org.apache.commons.beanutils.Converter;
public class BeanSupport {
private static final BeanUtilsBean beanUtils = new BeanUtilsBean();
+ private static final Map<Converter, Class> customConverters = new
HashMap<>();
static {
- // This is to customize the BeanUtils to use Fluent Proeprties as well
+ // This is to customize the BeanUtils to use Fluent Properties as well
beanUtils.getPropertyUtils().addBeanIntrospector(new
FluentPropertyBeanIntrospectorWithIgnores());
}
public static void registerConverter(Converter converter, Class type) {
synchronized (beanUtils) {
beanUtils.getConvertUtils().register(converter, type);
+ customConverters.put(converter, type);
}
}
+ public static void customise(BeanUtilsBean bean) {
+ synchronized (beanUtils) {
+ customConverters.forEach((key, value) ->
bean.getConvertUtils().register(key, value));
+ }
+ bean.getPropertyUtils().addBeanIntrospector(new
FluentPropertyBeanIntrospectorWithIgnores());
+ }
+
public static <P> P copyData(P source, P target) throws Exception {
synchronized (beanUtils) {
beanUtils.copyProperties(source, target);
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 3c13f70..8414461 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
@@ -99,7 +99,7 @@ import
org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings;
import org.apache.activemq.artemis.utils.Env;
import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader;
import org.apache.activemq.artemis.utils.critical.CriticalAnalyzerPolicy;
-import
org.apache.activemq.artemis.utils.uri.FluentPropertyBeanIntrospectorWithIgnores;
+import org.apache.activemq.artemis.utils.uri.BeanSupport;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.ConvertUtilsBean;
import org.apache.commons.beanutils.Converter;
@@ -504,7 +504,7 @@ public class ConfigurationImpl implements Configuration,
Serializable {
return (T) SimpleString.toSimpleString(value.toString());
}
}, SimpleString.class);
- beanUtils.getPropertyUtils().addBeanIntrospector(new
FluentPropertyBeanIntrospectorWithIgnores());
+ BeanSupport.customise(beanUtils);
beanUtils.populate(this, beanProperties);
}