[
https://issues.apache.org/jira/browse/CAMEL-27765?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27765:
--------------------------------
Component/s: camel-file
(was: camel-core)
Description:
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. The ftp and sftp consumers use the same
class, so they get it too.
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.
was:
An exception inside a {{doTry}} that no {{doCatch}} matches is never logged by
the error handler. Outside a {{doTry}}, the same exception is logged as ERROR
("Failed delivery for ..." with the message history). Inside, the error handler
is quiet, and what the user sees depends on the consumer.
With a timer, the consumer logs a WARN with the exception. With a file
consumer, the only line is the rollback, every poll, and the exception is not
in the log at all:
{noformat}
WARN ... GenericFileOnCompletion : Rollback file strategy:
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@7dbd938b
for file: GenericFile[a.txt]
{noformat}
So a user who adds a {{doTry}} with a {{doCatch}} for one exception gets less
logging for all other exceptions than with no {{doTry}} at all. This cost time
when building the route/cache example in camel-jbang-examples: an exception
inside the {{doTry}} made the file consumer roll back each order, and the log
did not say why.
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}
Expected: the exception that leaves the {{doTry}} is logged as it would be
without the {{doTry}}: the "Failed delivery" ERROR with the route, the node and
the message history.
Summary: camel-file - the rollback WARN does not say which exception
caused it (was: camel-core - an exception in doTry that no doCatch matches is
never logged by the error handler)
> 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-file
> Reporter: 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. The ftp and sftp consumers use the
> same class, so they get it too.
> 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)