Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/508#discussion_r94982612
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/core/mgmt/persist/DeserializingClassRenamesProvider.java
 ---
    @@ -43,49 +37,30 @@
      * See karaf/init/src/main/resources/OSGI-INF/blueprint/blueprint.xml
      */
     @Beta
    -public class DeserializingClassRenamesProvider {
    -    private static final Logger LOG = 
LoggerFactory.getLogger(DeserializingClassRenamesProvider.class);
    +public class DeserializingClassRenamesProvider extends 
DeserializingProvider{
     
    -    private static final List<ConfigLoader> loaders = 
Lists.newCopyOnWriteArrayList();
    -    static {
    -        loaders.add(new ClasspathConfigLoader());
    -    }
    -    
    -    private static volatile Map<String, String> cache;
    +    private static DeserializingClassRenamesProvider instance;
     
    -    public static List<ConfigLoader> getLoaders() {
    -        return loaders;
    +    public static DeserializingClassRenamesProvider getInstance(){
    +        if (instance == null) instance = new 
DeserializingClassRenamesProvider();
    +        return instance;
         }
     
    -    @Beta
    -    public static Map<String, String> loadDeserializingClassRenames() {
    -        synchronized (DeserializingClassRenamesProvider.class) {
    -            if (cache == null) {
    -                MutableMap.Builder<String, String> builder = 
MutableMap.<String, String>builder();
    -                for (ConfigLoader loader : loaders) {
    -                    builder.putAll(loader.load());
    -                }
    -                cache = builder.build();
    -                LOG.info("Class-renames cache loaded, size {}", 
cache.size());
    -            }
    -            return cache;
    -        }
    +    private DeserializingClassRenamesProvider(){
    +        super(Arrays.asList(new ConfigLoader[]{
    +                new ClasspathConfigLoader()
    +        }));
         }
     
         /**
          * Handles inner classes, where the outer class has been renamed. For 
example:
    -     * 
    +     *
          * {@code findMappedName("com.example.MyFoo$MySub")} will return 
{@code com.example.renamed.MyFoo$MySub}, if
          * the renamed contains {@code com.example.MyFoo: 
com.example.renamed.MyFoo}.
          */
         @Beta
    -    public static String findMappedName(String name) {
    -        return 
Reflections.findMappedNameAndLog(DeserializingClassRenamesProvider.loadDeserializingClassRenames(),
 name);
    +    public String findMappedName(String name) {
    +        return 
Reflections.findMappedNameAndLog(DeserializingClassRenamesProvider.getInstance().loadDeserializingMapping(),
 name);
    --- End diff --
    
    This can just call `loadDeserializingMapping(...)` - it should be the same 
instance as is returned by `DeserializingClassRenamesProvider.getInstance()`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to