You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2022/01/25 14:58:54 UTC

[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3928: ARTEMIS-3627 - fix regression in CriticalCrashTest - statically confi…

gemmellr commented on a change in pull request #3928:
URL: https://github.com/apache/activemq-artemis/pull/3928#discussion_r791798013



##########
File path: artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/BeanSupport.java
##########
@@ -35,18 +35,27 @@
 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) {
+      for (Map.Entry<Converter, Class> existing : customConverters.entrySet()) {
+         bean.getConvertUtils().register(existing.getKey(), existing.getValue());
+      }

Review comment:
       The other customConverters usage is synchronized, so this probably should be also.
   
   Could be nicer with:
   ```
         customConverters.forEach((key, value) -> {
            bean.getConvertUtils().register(key, value);
         });
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org