[
https://issues.apache.org/jira/browse/CAMEL-18874?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17675585#comment-17675585
]
Moshe Elisha edited comment on CAMEL-18874 at 1/11/23 2:02 PM:
---------------------------------------------------------------
[~davsclaus] what do you recommend regarding backward compatibility?
I see that at least in the Camel project, only
SalesforceConsumer#handleException is overriding (but I'm not sure why).
If I can assume no one else in the world is overriding (or ignore them), I can
do something like the below.
Even with the below approach, backward compatibility might break as we will now
invoke "handleException(message, exchange, t)" instead of
"handleException(message, t)".
{{protected void handleException(Throwable t) {}}
{{ handleException(null, null, t);}}
{{}}}
{{protected void handleException(String message, Throwable t) {}}
{{ handleException(message, null, t);}}
{{}}}
{{protected void handleException(String message, Exchange exchange, Throwable
t) {}}
{{ Throwable newt = (t == null) ? new IllegalArgumentException("Handling
[null] exception") : t;}}
{{{}// This "if" is to maximize backward compatibility
otherw{}}}{{{}ise calling {}}}{{handleException(message, exchange, newt) would
have been much nicer.}}
{{ if (message == null && exchange == null) { }}
{{ getExceptionHandler().handleException(newt);}}
{{ } else if (exchange == null) {}}
{{ getExceptionHandler().handleException(message, newt);}}
{{ } else {}}
{{ getExceptionHandler().handleException(message, exchange, newt);}}
{{ }}}
{{}}}
was (Author: elishamoshe):
[~davsclaus] what do you recommend regarding backward compatibility?
I see that at least in the Camel project, only
SalesforceConsumer#handleException is overriding (but I'm not sure why).
If I can assume no one else in the world is overriding (or ignore them), I can
do something like the below.
Even with the below approach, backward compatibility might break as we will now
invoke "handleException(message, exchange, t)" instead of
"handleException(message, t)".
{{protected void handleException(Throwable t) {}}
{{ handleException(null, null, t);}}
{{}}}
{{protected void handleException(String message, Throwable t) {}}
{{ handleException(message, null, t);}}
{{}}}
{{protected void handleException(String message, Exchange exchange, Throwable
t) {}}
{{ Throwable newt = (t == null) ? new IllegalArgumentException("Handling
[null] exception") : t;}}
{{{}// This "if" is to maximize backward compatibility
otherw{}}}{{{}ise calling {}}}{{{}handleException(message, exchange, newt)
would have been much nicer.{}}}{{{}{}}}
{{ if (message == null && exchange == null) { }}
{{ getExceptionHandler().handleException(newt);}}
{{ } else if (exchange == null) {}}
{{ getExceptionHandler().handleException(message, newt);}}
{{ } else {}}
{{ getExceptionHandler().handleException(message, exchange, newt);}}
{{ }}}
{{}}}
> camel-file - When possible, pass the exchange to the exception handler
> ----------------------------------------------------------------------
>
> Key: CAMEL-18874
> URL: https://issues.apache.org/jira/browse/CAMEL-18874
> Project: Camel
> Issue Type: Improvement
> Components: camel-file, camel-ftp, camel-sftp
> Affects Versions: 3.19.0
> Reporter: Moshe Elisha
> Priority: Major
> Fix For: 3.21.0
>
>
> Several places use the
> {{org.apache.camel.spi.ExceptionHandler#handleException(java.lang.String,
> java.lang.Throwable)}}
>
> instead of
>
> {{org.apache.camel.spi.ExceptionHandler#handleException(java.lang.String,
> org.apache.camel.Exchange, java.lang.Throwable)}}
>
> even when the exchange is available in scope.
> One example for that is
> org.apache.camel.component.file.GenericFileConsumer#processExchange
>
> The exchange is sometimes needed for additional information. For example, if
> a download of a file from an SFTP server fails, the exchange will hold the
> file details for logging purposes.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)