Uploaded image for project: 'DeltaSpike'
  1. DeltaSpike
  2. DELTASPIKE-1207

Incorrect exception handling in DynamicMBeanWrapper.invoke()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.1
    • 1.7.2
    • Core
    • None

    Description

      DynamicMBeanWrapper.invoke(String, Object[], String[]) just re-throws any exception as a RuntimeException.
      This makes it impossible for a client to determine the specific exception which might have been thrown on purpose by the MBean method. See also:

      JavaDoc of javax.management.DynamicMBean.invoke(String, Object[], String[])
           ...
           * @exception MBeanException  Wraps a <CODE>java.lang.Exception</CODE> thrown by the MBean's invoked method.
           * @exception ReflectionException  Wraps a <CODE>java.lang.Exception</CODE> thrown while trying to invoke the method
           */
          public Object invoke(String actionName, Object params[], String signature[])
              throws MBeanException, ReflectionException ;
      

      So the correct approach is to handle InvocationTargetException specifically by wrapping it's cause in a MBeanException and throwing that MBeanException.
      All other exceptions should be wrapped in a ReflectionException.

      PS: I filed DELTASPIKE-984 some time ago which led to a slight improvement of the very same invoke method but obviously my suggestions regarding MBeanException haven't been considered (I don't know why).

      Attachments

        Issue Links

          Activity

            People

              johndament John D. Ament
              famod Falko Modler
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: