Aries
  1. Aries
  2. ARIES-259

MBeans not getting unregistered reliably

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.1
    • Component/s: JMX
    • Labels:
      None

      Description

      Closing the MBeanServiceTracker asyncronously triggers JMXAgent.unregisterBeans(MBeanServer server)

      If there is a unexpected exception while unregistering an MBeanHandler the ones coming after it will not get unregitered.
      In particular I am seeing an unguarded postDeregister hook.

      Caused by: java.lang.IllegalStateException: Invalid BundleContext.
      at org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:393)
      at org.apache.felix.framework.BundleContextImpl.removeBundleListener(BundleContextImpl.java:170)
      at org.apache.aries.jmx.framework.BundleState.shutDownDispatcher(BundleState.java:353)
      at org.apache.aries.jmx.framework.BundleState.postDeregister(BundleState.java:293)
      at org.apache.aries.jmx.framework.RegistrableStandardEmitterMBean.postDeregister(RegistrableStandardEmitterMBean.java:69)
      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.postDeregisterInvoke(DefaultMBeanServerInterceptor.java:1065)

        Issue Links

          Activity

          Hide
          Adam Wojtuniak added a comment -

          BundleState.shutDownDispatcher is missing a check for bundleContext validity.
          BundleContext could be no valid cause of asynchronous unregistration of MBeans.

          Show
          Adam Wojtuniak added a comment - BundleState.shutDownDispatcher is missing a check for bundleContext validity. BundleContext could be no valid cause of asynchronous unregistration of MBeans.
          Hide
          Thomas Diesler added a comment -

          patch attached

          Show
          Thomas Diesler added a comment - patch attached
          Hide
          Thomas Diesler added a comment -

          This also pertains to ServiceState and generally to any uncought Exception in the JMXAgent.unregisterBeans(MBeanServer server) loop.

          BTW, why is the MBean register/unregister work been done asynchronously. this makes my remote osgi testsuite that delegates to JMX much more complicated.

          Show
          Thomas Diesler added a comment - This also pertains to ServiceState and generally to any uncought Exception in the JMXAgent.unregisterBeans(MBeanServer server) loop. BTW, why is the MBean register/unregister work been done asynchronously. this makes my remote osgi testsuite that delegates to JMX much more complicated.
          Hide
          Adam Wojtuniak added a comment -

          patch submitted.

          Answer to your question:
          We decided to use SingleThreadExecutor for better management of MBeans lifecycle. Except framework services the rest is dynamic and
          of course MBeanServer which is also registered as a service (for compendium services and MBean server we are using serviceTracker.).
          We are not treating MBeanServer as a static service. So we can't assume that MBean will be registered after jmx bundle is started.
          SingleThreadExecutor perfectly fit in that situation cause we can guarantee sequential order of MBeans registration and unregistration.

          thanks,
          Adam

          Show
          Adam Wojtuniak added a comment - patch submitted. Answer to your question: We decided to use SingleThreadExecutor for better management of MBeans lifecycle. Except framework services the rest is dynamic and of course MBeanServer which is also registered as a service (for compendium services and MBean server we are using serviceTracker.). We are not treating MBeanServer as a static service. So we can't assume that MBean will be registered after jmx bundle is started. SingleThreadExecutor perfectly fit in that situation cause we can guarantee sequential order of MBeans registration and unregistration. thanks, Adam

            People

            • Assignee:
              Adam Wojtuniak
              Reporter:
              Thomas Diesler
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development