You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by rg...@apache.org on 2015/09/10 06:31:40 UTC

svn commit: r1702162 - in /zookeeper/branches/branch-3.5: CHANGES.txt src/java/main/org/apache/zookeeper/jmx/MBeanRegistry.java

Author: rgs
Date: Thu Sep 10 04:31:40 2015
New Revision: 1702162

URL: http://svn.apache.org/r1702162
Log:
ZOOKEEPER-2270: Allow MBeanRegistry to be overridden for better unit tests
(Jordan Zimmerman via rgs)

Modified:
    zookeeper/branches/branch-3.5/CHANGES.txt
    zookeeper/branches/branch-3.5/src/java/main/org/apache/zookeeper/jmx/MBeanRegistry.java

Modified: zookeeper/branches/branch-3.5/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.5/CHANGES.txt?rev=1702162&r1=1702161&r2=1702162&view=diff
==============================================================================
--- zookeeper/branches/branch-3.5/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.5/CHANGES.txt Thu Sep 10 04:31:40 2015
@@ -234,6 +234,9 @@ IMPROVEMENTS:
   ZOOKEEPER-1423: 4lw and jmx should expose the size of the datadir/datalogdir
   (Edward Ribeiro via rgs)
 
+  ZOOKEEPER-2270: Allow MBeanRegistry to be overridden for better unit tests
+  (Jordan Zimmerman via rgs)
+
 Release 3.5.0 - 8/4/2014
 
 NEW FEATURES:

Modified: zookeeper/branches/branch-3.5/src/java/main/org/apache/zookeeper/jmx/MBeanRegistry.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.5/src/java/main/org/apache/zookeeper/jmx/MBeanRegistry.java?rev=1702162&r1=1702161&r2=1702162&view=diff
==============================================================================
--- zookeeper/branches/branch-3.5/src/java/main/org/apache/zookeeper/jmx/MBeanRegistry.java (original)
+++ zookeeper/branches/branch-3.5/src/java/main/org/apache/zookeeper/jmx/MBeanRegistry.java Thu Sep 10 04:31:40 2015
@@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory;
 public class MBeanRegistry {
     private static final Logger LOG = LoggerFactory.getLogger(MBeanRegistry.class);
     
-    private static MBeanRegistry instance = new MBeanRegistry(); 
+    private static volatile MBeanRegistry instance = new MBeanRegistry();
     
     private final Object LOCK = new Object();
     
@@ -52,6 +52,15 @@ public class MBeanRegistry {
     
     private MBeanServer mBeanServer;
 
+    /**
+     * Useful for unit tests. Change the MBeanRegistry instance
+     *
+     * @param instance new instance
+     */
+    public static void setInstance(MBeanRegistry instance) {
+        MBeanRegistry.instance = instance;
+    }
+
     public static MBeanRegistry getInstance() {
         return instance;
     }