Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8364227

MBeanServer registerMBean throws NPE

XMLWordPrintable

    • b14
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      When MBeanServer MBeanServer(null, name), it should throw "RuntimeOperationsException – Wraps a java.lang.IllegalArgumentException: The object passed in parameter is null or no object name is specified."
      But it throws NPE

      ACTUAL -
      Exception in thread "main" java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "object" is null

      ---------- BEGIN SOURCE ----------
      import javax.management.MBeanServer;
      import javax.management.MBeanServerFactory;
      import javax.management.ObjectName;
      import javax.management.RuntimeOperationsException;

      public class ExceptionDiagnosisTest {
          public static void main(String[] args) throws Exception {
              try {
                  MBeanServer mbs = MBeanServerFactory.newMBeanServer();
                  ObjectName name = new ObjectName("a:b=c");
                  mbs.registerMBean(null, name);
              } catch (RuntimeOperationsException e) {
                  e.printStackTrace();
              }

          }
      }
      ---------- END SOURCE ----------

            kevinw Kevin Walls
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: