You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "John D. Ament (JIRA)" <ji...@apache.org> on 2016/10/28 00:49:58 UTC

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

     [ https://issues.apache.org/jira/browse/DELTASPIKE-1207?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John D. Ament resolved DELTASPIKE-1207.
---------------------------------------
    Resolution: Fixed

PR merged, thanks!

> 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
>            Assignee: John D. Ament
>             Fix For: 1.7.2
>
>
> {{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)