zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r1702156 - in /zookeeper/trunk: CHANGES.txt src/java/main/org/apache/zookeeper/jmx/MBeanRegistry.java
Date Thu, 10 Sep 2015 04:07:42 GMT
Author: rgs
Date: Thu Sep 10 04:07:41 2015
New Revision: 1702156

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

Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/src/java/main/org/apache/zookeeper/jmx/MBeanRegistry.java

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1702156&r1=1702155&r2=1702156&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Thu Sep 10 04:07:41 2015
@@ -250,6 +250,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/trunk/src/java/main/org/apache/zookeeper/jmx/MBeanRegistry.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/jmx/MBeanRegistry.java?rev=1702156&r1=1702155&r2=1702156&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/jmx/MBeanRegistry.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/jmx/MBeanRegistry.java Thu Sep 10 04:07:41
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;
     }



Mime
View raw message