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

No InstanceAlreadyExistsException for the second registration of an MXBean object under dif. name

XMLWordPrintable

    • b06
    • generic
    • generic

        The MXBean spec says:

        ---------------------------------------8<----------------------------------------
        If the same MXBean were registered under two different ObjectNames, a reference to that MXBean from another MXBean would be ambiguous. Therefore, if an MXBean object is already registered in an MBean Server and an attempt is made to register it in the same MBean Server under another name, the result is an InstanceAlreadyExistsException.
        ---------------------------------------8<----------------------------------------

        However, the following code does not throw the InstanceAlreadyExistsException:
        ---------------------------------------8<----------------------------------------
                    ObjectName objectName1 = new ObjectName("test:index=1");
                    ObjectName objectName2 = new ObjectName("test:index=2");
                    MBeanServer mbs = MBeanServerFactory.createMBeanServer();
                    MXBC_SimpleClass01 mxBeanObject = new MXBC_SimpleClass01();
                    
                    mbs.registerMBean(mxBeanObject, objectName1);
                    
                    mbs.registerMBean(mxBeanObject, objectName2);
                    System.out.println("InstanceAlreadyExistsException is not thrown.");
        ---------------------------------------8<----------------------------------------
        (the sample test class attached)

              emcmanus Eamonn McManus
              ashusher Alexander Shusherov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: