[ https://issues.apache.org/jira/browse/DELTASPIKE-1207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15586765#comment-15586765 ]
ASF GitHub Bot commented on DELTASPIKE-1207: -------------------------------------------- GitHub user famod opened a pull request: https://github.com/apache/deltaspike/pull/66 DELTASPIKE-1207: fix exception handling in DynamicMBeanWrapper.invoke() Ok, this fix enables the transfer of a exception thrown by the MBean method to the client. Tomorrow I'm going to update the JIRA ticket with some output examples. Not sure about the logging removal, though. In my project we have a logging interceptor for MBeans which logs exceptions anyway so another log entry from DynamicMBeanWrapper just "pollutes" the logfile. Exceptions aren't swallowed either, so ... You can merge this pull request into a Git repository by running: $ git pull https://github.com/famod/deltaspike DELTASPIKE-1207 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/deltaspike/pull/66.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #66 ---- commit 0bd61f2fa4d2c08b7554d5f2826b9c99cad8e7a6 Author: famod <f.mod...@gmx.net> Date: 2016-10-16T20:17:47Z DELTASPIKE-1207: fix exception handling in DynamicMBeanWrapper.invoke() commit 6252c3998756b1f2eb6e0835c9583ec489f88cd6 Author: famod <f.mod...@gmx.net> Date: 2016-10-16T20:28:29Z DELTASPIKE-1207: fix exception handling in DynamicMBeanWrapper.invoke() fix tabs commit d19e47b0b9252b046e7e1a82be0ba6b7608f5e07 Author: famod <f.mod...@gmx.net> Date: 2016-10-16T20:55:18Z DELTASPIKE-1207: fix exception handling in DynamicMBeanWrapper.invoke() remove unnecessary cast to Exception commit 717f6fd08aaa38089002d0832da3a01529474bb1 Author: famod <f.mod...@gmx.net> Date: 2016-10-16T21:24:49Z DELTASPIKE-1207: fix exception handling in DynamicMBeanWrapper.invoke() cause needs to be passed to MBeanException constructor, not e (and so casting is needed after all) commit d341dc8f0900054c5e7f46d1833ede749c0c597f Author: famod <f.mod...@gmx.net> Date: 2016-10-18T21:40:24Z DELTASPIKE-1207: fix exception handling in DynamicMBeanWrapper.invoke() - don't wrap MBeanException directly thrown by the MBean method - document exception handling in @JmxManaged ---- > 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)