camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Babak Vahdat (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-5598) BeanProcessor - InvocationTargetException propagates cause instead of target
Date Wed, 12 Sep 2012 11:31:07 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-5598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13453904#comment-13453904
] 

Babak Vahdat commented on CAMEL-5598:
-------------------------------------

Actually it does *not* make any difference which method you would use (getTargetException()
or getCause()) as [Throwable.getCause()|http://docs.oracle.com/javase/6/docs/api/java/lang/Throwable.html#getCause()]

is overriden by this class returning the target field (the same as getTargetException()):

{code:java}
public class InvocationTargetException extends Exception {
...
    /**
     * Get the thrown target exception.
     *
     * <p>This method predates the general-purpose exception chaining facility.
     * The {@link Throwable#getCause()} method is now the preferred means of
     * obtaining this information.
     *
     * @return the thrown target exception (cause of this exception).
     */
    public Throwable getTargetException() {
	return target;
    }

    /**
     * Returns the cause of this exception (the thrown target exception,
     * which may be <tt>null</tt>).
     *
     * @return  the cause of this exception.
     * @since   1.4
     */
    public Throwable getCause() {
        return target;
    }
}
{code}

However getCause() should be the prefered one which was introduced by Joshua Bloch in JDK
1.4. And this's what BeanProcessor already does.

                
> BeanProcessor - InvocationTargetException propagates cause instead of target
> ----------------------------------------------------------------------------
>
>                 Key: CAMEL-5598
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5598
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.10.0
>            Reporter: Gilles Letare
>            Assignee: Babak Vahdat
>            Priority: Trivial
>
> In BeanProcessor.process, InvocationTargetException's are caught, but the exception set
on the exchange is the cause instead of the target.
> See lines 164-180 on version 2.10.0:
> {code}
> try {
>     ...
>     value = invocation.proceed(callback, sync);
>     ...
> } catch (InvocationTargetException e) {
>     exchange.setException(e.getCause());
>     ...
> }
> {code}
> I think it should be:
> {code}
> } catch (InvocationTargetException e) {
>     exchange.setException(e.getTargetException());
>     ...
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message