You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Falko Modler (JIRA)" <ji...@apache.org> on 2016/10/15 23:05:20 UTC

[jira] [Created] (DELTASPIKE-1207) Incorrect exception handling in DynamicMBeanWrapper.invoke()

Falko Modler created DELTASPIKE-1207:
----------------------------------------

             Summary: Incorrect exception handling in DynamicMBeanWrapper.invoke()
                 Key: DELTASPIKE-1207
                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-1207
             Project: DeltaSpike
          Issue Type: Bug
          Components: Core
    Affects Versions: 1.7.1
            Reporter: Falko Modler


{{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:
{code:java|title=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 ;
{code}
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).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)