brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #508: Alternate names for JcloudsProviders
Date Fri, 06 Jan 2017 17:32:38 GMT
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message