CAMEL-24231: camel-file - Fix pollEnrich with dynamic fileName using exchange properties - #24994
Conversation
…exchange properties Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet
left a comment
There was a problem hiding this comment.
Claude Code on behalf of gnodet
LGTM — clean, well-scoped fix.
Two issues addressed:
-
Exchange properties not copied —
GenericFileHelper.createDummy()now copies exchange properties to the dummy exchange, so${exchangeProperty.target}in apollEnrichfileNameexpression resolves correctly during thePollDynamicAwareoptimization. Without this, the expression evaluated tonullon the dummy and the filename filter was effectively bypassed. -
Variables copy bug — The
dynamic.hasVariables()block was previously nested inside thedynamic.getMessage().hasHeaders()guard, meaning variables wouldn't be copied for exchanges with variables but no headers. Now correctly moved outside.
Test is well-designed — verifies both the filename resolution and endpoint optimization reuse, with a negative case (non-existent file → null body).
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 473 tested, 29 compile-only — current: 473 all testedMaveniverse Scalpel detected 502 affected modules (current approach: 473).
|
Summary
Claude Code on behalf of davsclaus
Fixes CAMEL-24231.
GenericFileHelper.createDummy()creates a dummy exchange for evaluatingfileNameexpressions duringpollEnrichoptimization (PollDynamicAware), but it only copies headers from the incoming exchange — not exchange properties. WhenfileNameuses${exchangeProperty.xxx}, the expression evaluates tonullon the dummy, effectively bypassing the filename filter and picking up any file in the directory.The workaround is to set
allowOptimisedComponents(false)on the pollEnrich.Changes:
GenericFileHelper.createDummy()hasHeaders()guard, so variables would not be copied when the exchange had variables but no headersPollDynamicFileNameExchangePropertyTestthat verifiespollEnrichwithfileName=${exchangeProperty.target}works correctly with the optimization enabledReported by Marcus Ionker on the Camel users mailing list.
Test plan
PollDynamicFileNameExchangePropertyTest— two cases: matching file found, and no matching file (returns null body)PollDynamicFileNameOptimizeDisabledTest,PollEnricherFileTest,PollEnricherFileMaxMessagesPerPollTest,PollEnrichHeaderPropagationTest,PollEnrichSimpleMoveTest)🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com