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:
... * @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
- links to