Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1BFF8200BF4 for ; Fri, 6 Jan 2017 18:32:40 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 1AB43160B4C; Fri, 6 Jan 2017 17:32:40 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 69BC3160B49 for ; Fri, 6 Jan 2017 18:32:39 +0100 (CET) Received: (qmail 91042 invoked by uid 500); 6 Jan 2017 17:32:38 -0000 Mailing-List: contact dev-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list dev@brooklyn.apache.org Received: (qmail 90940 invoked by uid 99); 6 Jan 2017 17:32:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jan 2017 17:32:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 215AADF9FD; Fri, 6 Jan 2017 17:32:38 +0000 (UTC) From: aledsage To: dev@brooklyn.apache.org Reply-To: dev@brooklyn.apache.org References: In-Reply-To: Subject: [GitHub] brooklyn-server pull request #508: Alternate names for JcloudsProviders Content-Type: text/plain Message-Id: <20170106173238.215AADF9FD@git1-us-west.apache.org> Date: Fri, 6 Jan 2017 17:32:38 +0000 (UTC) archived-at: Fri, 06 Jan 2017 17:32:40 -0000 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 loaders = Lists.newCopyOnWriteArrayList(); - static { - loaders.add(new ClasspathConfigLoader()); - } - - private static volatile Map cache; + private static DeserializingClassRenamesProvider instance; - public static List 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. ---