Gaelle Fournier created CAMEL-24392:
---------------------------------------
Summary: BacklogTracerRouteAdvice drains non-re-readable
InputStream body before stream caching
Key: CAMEL-24392
URL: https://issues.apache.org/jira/browse/CAMEL-24392
Project: Camel
Issue Type: Bug
Affects Versions: 4.22.0, 4.18.5
Reporter: Gaelle Fournier
CAMEL-22858 introduced {{BacklogTracerRouteAdvice}} in
{{CamelInternalProcessor.addRouteLifecycleAdvice()}}. This route-level advice
runs _before_ any channel-level advice, including {{StreamCachingAdvice}}. Its
{{before()}} method calls {{MessageHelper.dumpAsJSonObject()}} on the exchange
message.
When the body is a {{WrappedFile}} wrapping a non-re-readable {{InputStream}}
(e.g. SFTP/FTP with {{streamDownload(true)}}), and
{{BacklogTracer.bodyIncludeFiles}} is {{true}} (the default),
{{extractValueForLogging()}} type-converts the {{WrappedFile}} to {{String}},
draining the underlying {{InputStream}}. {{StreamCachingAdvice}} then caches an
already-exhausted stream, resulting in an empty body.
In 4.17, the only tracer dump was the per-node {{BacklogTracerAdvice}} in
{{DefaultChannel}}, which runs _after_ {{StreamCachingAdvice}} and always read
a re-readable {{InputStreamCache}}.
Triggered when {{camel.main.profile=dev}} (sets both {{backlogTracingStandby}}
and {{messageHistory}} to {{true}}), which includes Quarkus dev mode.
See:
https://camel.zulipchat.com/#narrow/channel/257302-camel-quarkus/topic/.60camel-quarkus-ftp.60.20and.20.60.2EstreamDownload.28true.29.60.20-.3E.20no.20body/with/616317948
*Workaround*
{code}
camel.trace.body-include-files=false
{code}
*Reproducer*
[https://github.com/turing85/quarkus-camel-sftp-no-body] (run with {{mvn
quarkus:dev}})
--
This message was sent by Atlassian Jira
(v8.20.10#820010)