[ 
https://issues.apache.org/jira/browse/CAMEL-27765?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen resolved CAMEL-27765.
---------------------------------
    Resolution: Fixed

Merged to main for 4.25.0 via https://github.com/apache/camel/pull/31103 
(commit 73cd8005fe).

_Claude Code on behalf of Claus Ibsen (davsclaus)_

> camel-file - the rollback WARN does not say which exception caused it
> ---------------------------------------------------------------------
>
>                 Key: CAMEL-27765
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27765
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-azure, camel-file, camel-ftp, camel-smb
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.25.0
>
>
> When a file route fails, the file consumer rolls the file back and logs a 
> WARN, but the WARN does not say why. The exception is not in the line, so the 
> user sees the file roll back on every poll and has no reason:
> {noformat}
> WARN ... GenericFileOnCompletion : Rollback file strategy: 
> org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@7dbd938b
>  for file: GenericFile[a.txt]
> {noformat}
> Often the route's error handler has logged the exception already, but not 
> always. One case: an exception inside a {{doTry}} that no {{doCatch}} 
> matches. It leaves the {{doTry}} like an uncaught exception leaves a Java 
> try/catch, and the error handler does not log it. A timer consumer then logs 
> a WARN with the exception. The file consumer logs only the rollback line 
> above, so the exception is never logged at all. This cost time when building 
> the route/cache example in camel-jbang-examples.
> The line is in {{GenericFileOnCompletion}} (camel-file, the rollback in 
> {{processStrategyRollback}}):
> {code:java}
> LOG.warn("Rollback file strategy: {} for file: {}", processStrategy, file);
> {code}
> Suggested fix: add the exception from {{exchange.getException()}} to this 
> WARN, with its message (and the stack trace, as the timer consumer does), so 
> the line says why the file is rolled back. All consumers built on 
> {{GenericFileConsumer}} log the same line, so one fix covers them all: file, 
> ftp, ftps and sftp (camel-ftp), azure-files and smb.
> Reproduce with Camel 4.23.0 and {{camel run}}, with a file {{a.txt}} in 
> {{in/}}:
> {code:yaml}
> - route:
>     id: file-try
>     from:
>       uri: file:in
>       parameters:
>         noop: true
>       steps:
>         - doTry:
>             steps:
>               - throwException:
>                   exceptionType: java.lang.IllegalStateException
>                   message: boom inside doTry
>             doCatch:
>               - exception:
>                   - java.io.IOException
>                 steps:
>                   - log: caught io
> {code}
> Today: only the rollback line, every poll, with no "boom inside doTry" 
> anywhere in the log. Expected: the rollback WARN includes the 
> IllegalStateException and its message.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to