Camel
  1. Camel
  2. CAMEL-4230

BeanProcessor - Improved exception message if failed to invoke method

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.9.2, 2.10.0
    • Component/s: camel-core
    • Labels:
      None
    • Estimated Complexity:
      Novice

      Description

      See nabble
      http://camel.465427.n5.nabble.com/How-to-impl-bean-side-of-proxy-w-Future-return-tp4581104p4581104.html

      If for some reason the method cannot be invoked, you may get a caused exception

      Caused by: java.lang.IllegalAccessException: Class org.apache.camel.component.bean.MethodInfo can not access a member of class com.sonatype.overlord.xpi.AsyncProxyBeanCamelTest$1 with modifiers "public"
             at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
             at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:329)
             at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:231)
             at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:169)
      

      We should catch this and provide a wrapped exception with a more descriptive error message, about the bean and method attempted to invoke.

      1. MethodInfo.patch
        1 kB
        Michał Warecki

        Activity

        Hide
        Michał Warecki added a comment -

        I think it can be done as in the case IllegalArgumentException:

        protected Object invoke(Method mth, Object pojo, Object[] arguments, Exchange exchange) throws InvocationTargetException {
        try

        { return mth.invoke(pojo, arguments); }

        catch(IllegalAccessException e)

        { throw new RuntimeExchangeException("IllegalAccessException occurred invoking method: " + mth + " using arguments: " + Arrays.asList(arguments), exchange, e); }

        catch (IllegalArgumentException e)

        { throw new RuntimeExchangeException("IllegalArgumentException occurred invoking method: " + mth + " using arguments: " + Arrays.asList(arguments), exchange, e); }

        }

        Show
        Michał Warecki added a comment - I think it can be done as in the case IllegalArgumentException: protected Object invoke(Method mth, Object pojo, Object[] arguments, Exchange exchange) throws InvocationTargetException { try { return mth.invoke(pojo, arguments); } catch(IllegalAccessException e) { throw new RuntimeExchangeException("IllegalAccessException occurred invoking method: " + mth + " using arguments: " + Arrays.asList(arguments), exchange, e); } catch (IllegalArgumentException e) { throw new RuntimeExchangeException("IllegalArgumentException occurred invoking method: " + mth + " using arguments: " + Arrays.asList(arguments), exchange, e); } }
        Hide
        Claus Ibsen added a comment -

        Thanks for the patch.

        Show
        Claus Ibsen added a comment - Thanks for the patch.

          People

          • Assignee:
            Claus Ibsen
            Reporter:
            Claus Ibsen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development