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:06:20 UTC

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

    [ https://issues.apache.org/jira/browse/DELTASPIKE-1207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15578892#comment-15578892 ] 

Falko Modler commented on DELTASPIKE-1207:
------------------------------------------

I'll try to come up with a pull request next week.

> 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)