JeetKunDoug commented on code in PR #2322:
URL: https://github.com/apache/cassandra/pull/2322#discussion_r1200624473


##########
src/java/org/apache/cassandra/utils/MBeanWrapper.java:
##########
@@ -33,62 +38,144 @@
  */
 public interface MBeanWrapper
 {
-    static final Logger logger = LoggerFactory.getLogger(MBeanWrapper.class);
+    Logger logger = LoggerFactory.getLogger(MBeanWrapper.class);
 
-    static final MBeanWrapper instance = 
Boolean.getBoolean("org.apache.cassandra.disable_mbean_registration") ?
-                                         new NoOpMBeanWrapper() :
-                                         new PlatformMBeanWrapper();
+    MBeanWrapper instance = create();
+    String IS_DISABLED_MBEAN_REGISTRATION = 
"org.apache.cassandra.disable_mbean_registration";
+    String IS_IN_JVM_DTEST = "org.apache.cassandra.is_in_jvm_dtest";
+    String MBEAN_REGISTRATION_CLASS = 
"org.apache.cassandra.mbean_registration_class";
+
+    static MBeanWrapper create()
+    {
+        // If we're running in the in-jvm dtest environment, always use the 
delegating
+        // mbean wrapper even if we start off with no-op, so it can be 
switched later
+        if (Boolean.getBoolean(IS_IN_JVM_DTEST))
+            return new DelegatingMbeanWrapper(getmBeanWrapper());
+
+        return getmBeanWrapper();
+    }
+
+    static MBeanWrapper getmBeanWrapper()
+    {
+        if (Boolean.getBoolean(IS_DISABLED_MBEAN_REGISTRATION))
+            return new NoOpMBeanWrapper();
+
+        String klass = System.getProperty(MBEAN_REGISTRATION_CLASS);
+        if (klass == null)
+            if (Boolean.getBoolean(IS_IN_JVM_DTEST))
+                return new NoOpMBeanWrapper();
+            else
+                return new PlatformMBeanWrapper();

Review Comment:
   Rereading the style guide, it does specifically say they _may_ be elided so 
I'm actually going to put them in, as I generally agree with you on this.
   
   Actually, the entire rest of the file has elided the braces for 
single-lines, so I'm going to leave it alone.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to