Uploaded image for project: 'DeltaSpike'
  1. DeltaSpike
  2. DELTASPIKE-984

DynamicMBeanWrapper throws misleading MBeanException saying that the required action does not exist when MBean method (deliberately) throws an exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.2
    • 1.5.1
    • Core
    • None

    Description

      See org.apache.deltaspike.core.impl.jmx.DynamicMBeanWrapper.invoke(String, Object[], String[]):

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

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            famod Falko Modler
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: