You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2022/01/03 07:29:34 UTC

[GitHub] [zookeeper] eolivelli commented on a change in pull request #1276: ZOOKEEPER-3497:Change MBeanRegistry to a standard singleton

eolivelli commented on a change in pull request #1276:
URL: https://github.com/apache/zookeeper/pull/1276#discussion_r777322284



##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/jmx/MBeanRegistry.java
##########
@@ -43,28 +43,26 @@
     public static final String DOMAIN = "org.apache.ZooKeeperService";
 
     private static final Logger LOG = LoggerFactory.getLogger(MBeanRegistry.class);
-    private static volatile MBeanRegistry instance = new MBeanRegistry();
 
     private final Object LOCK = new Object();
 
     private Map<ZKMBeanInfo, String> mapBean2Path = new ConcurrentHashMap<ZKMBeanInfo, String>();
 
     private MBeanServer mBeanServer;
 
-    /**
-     * Useful for unit tests. Change the MBeanRegistry instance
-     *
-     * @param instance new instance
-     */
-    public static void setInstance(MBeanRegistry instance) {
-        MBeanRegistry.instance = instance;
+    private static class MBeanRegistryHolder {

Review comment:
       Why do we need this additional class?




-- 
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: notifications-unsubscribe@zookeeper.apache.org

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