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

    https://github.com/apache/brooklyn-server/pull/508#discussion_r94981908
  
    --- 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();
    --- End diff --
    
    Need to be careful about synchronization for singletons. See Bloch's 
Effective Java second edition, item 3.
    
    I don't think we need to instantiate it lazily - we can do it as soon as 
this class is loaded. I'd change it to:
    ```
    private static final DeserializingClassRenamesProvider INSTANCE = new 
DeserializingClassRenamesProvider();
    ```



---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to