Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-3661

PluggableMBeanServerImpl.findDelegateForNewObject() rejects null ObjectName arg

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 9.0.0.Final
    • 8.0.0.Final
    • JMX
    • None
    • Hide

      Simply create an MBean that implements MBeanRegistration and computes its ObjectName within preRegister(). Next, try to register that MBean within JBoss specifying a null ObjectName.

      Show
      Simply create an MBean that implements MBeanRegistration and computes its ObjectName within preRegister(). Next, try to register that MBean within JBoss specifying a null ObjectName.

    Description

      According to the Javadoc on MBeanRegistration.preRegister(), one may register an MBean with a null ObjectName and let the MBean's preRegister() method compute the ObjectName.

      Unfortunately, org.jboss.as.jmx.PluggableMBeanServerImpl.findDelegateForNewObject() violates this contract – throwing an exception when the incoming ObjectName is null.

      This is a clear bug which breaks numerous JMX MBeans I've authored, which compute their own ObjectNames within preRegister().

      Ideally the result of preRegister would be used as an input to findDelegateForNewObject(), but unfortunately one of the inputs to preRegister() is the MBeanServer, which is, of course, what findDelegateForNewObject() is looking up. Given this circularity, it would seem that findDelegateForNewObject() should simply return rootMBeanServer for null ObjectName inputs. In any case it should not entirely fail to register such MBeans.

      Fortunately, I have a utility wrapper around MBean registration, so I've added the following hack immediately prior to actually registering the MBean to workaround this issue:

      /* Hack to work around JBoss Wildfly bug (https://issues.jboss.org/browse/WFLY-3661).
      This isn't really quite correct, of course, since this means preRegister() will get called twice,
      but it appears to be about the best we can do.
      */
      if ( objectName == null )
      if ( mbean instanceof MBeanRegistration )
      if ( "org.jboss.as.jmx.PluggableMBeanServerImpl".equals( mbeanserver.getClass().getName() ) )
      objectName = ((MBeanRegistration)mbean).preRegister( mbeanserver, objectName );

      where mbeanserver is obtained via ManagementFactory.getPlatformMBeanServer().

      Attachments

        Activity

          People

            kkhan1@redhat.com Kabir Khan
            JessHolle Jess Holle (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: