Falko Modler created DELTASPIKE-984:
---------------------------------------

             Summary: DynamicMBeanWrapper throws misleading MBeanException 
saying that the required action does not exist when MBean method (deliberately) 
throws an exception
                 Key: DELTASPIKE-984
                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-984
             Project: DeltaSpike
          Issue Type: Bug
          Components: Core
    Affects Versions: 1.0.2
            Reporter: Falko Modler


See {{org.apache.deltaspike.core.impl.jmx.DynamicMBeanWrapper.invoke(String, 
Object[], String[])}}:
{code:java}
        if (operations.containsKey(actionName))
        {
            final ClassLoader oldCl = 
Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(classloader);
            try
            {
                return operations.get(actionName).invoke(instance(), params);
            }
            catch (IllegalArgumentException e)
            {
                LOGGER.log(Level.SEVERE, actionName + "can't be invoked", e);
            }
            catch (IllegalAccessException e)
            {
                LOGGER.log(Level.SEVERE, actionName + "can't be invoked", e);
            }
            catch (InvocationTargetException e)
            {
                LOGGER.log(Level.SEVERE, actionName + "can't be invoked", e);
            }
            finally
            {
                Thread.currentThread().setContextClassLoader(oldCl);
            }
        }
        throw new MBeanException(new IllegalArgumentException(), actionName + " 
doesn't exist");
{code}
When the MBean method throws an exception, the wrapper catches and logs the 
{{InvocationTargetException}}. But as the last step a {{MBeanException}} with 
cause {{actionName + " doesn't exist"}} is thrown, regardless of what went 
wrong actually!

The "doesn't exist" exception should be moved into an else block.
The specificly caught exception should be wrapped into a new {{MBeanException}} 
which should be thrown afterwards. If wrapping is not possible due to 
classloadings constraints, at least the message of the original exception 
should be retained.



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

Reply via email to