Claus Ibsen created CAMEL-24231:
-----------------------------------
Summary: pollEnrich with dynamic fileName using exchangeProperty
fails due to missing properties in dummy exchange
Key: CAMEL-24231
URL: https://issues.apache.org/jira/browse/CAMEL-24231
Project: Camel
Issue Type: Bug
Components: camel-file
Reporter: Claus Ibsen
When using pollEnrich with a dynamic fileName expression that references
exchange properties (e.g. {{${exchangeProperty.target}}}), the PollDynamicAware
optimization creates a dummy exchange via {{GenericFileHelper.createDummy()}}
that does not copy exchange properties from the incoming exchange. This causes
the fileName expression to evaluate to null, effectively bypassing the filename
filter and picking up any file in the directory.
The workaround is to set {{allowOptimisedComponents(false)}} on the pollEnrich.
*Root cause:*
{{GenericFileHelper.createDummy()}} copies headers and variables from the
dynamic exchange but misses exchange properties. A secondary issue is that the
variables copy is nested inside the {{hasHeaders()}} guard, so variables are
not copied when the exchange has variables but no headers.
*Example route:*
{code:java}
from("direct:start")
.pollEnrich().simple("file:inbox?noop=true&fileName=${exchangeProperty.target}")
.timeout(500)
.to("mock:result");
{code}
*Fix:*
Copy exchange properties (and fix variables nesting) in
{{GenericFileHelper.createDummy()}}.
Reported by Marcus Ionker on the Camel users mailing list.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)