davsclaus opened a new pull request, #24994: URL: https://github.com/apache/camel/pull/24994
## Summary _Claude Code on behalf of davsclaus_ Fixes [CAMEL-24231](https://issues.apache.org/jira/browse/CAMEL-24231). `GenericFileHelper.createDummy()` creates a dummy exchange for evaluating `fileName` expressions during `pollEnrich` optimization (`PollDynamicAware`), but it only copies **headers** from the incoming exchange — not **exchange properties**. When `fileName` uses `${exchangeProperty.xxx}`, the expression evaluates to `null` on 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:** - Copy exchange properties from the dynamic exchange to the dummy exchange in `GenericFileHelper.createDummy()` - Fix secondary bug: variables copy was nested inside the `hasHeaders()` guard, so variables would not be copied when the exchange had variables but no headers - Add test `PollDynamicFileNameExchangePropertyTest` that verifies `pollEnrich` with `fileName=${exchangeProperty.target}` works correctly with the optimization enabled Reported by Marcus Ionker on the Camel users mailing list. ## Test plan - [x] New test `PollDynamicFileNameExchangePropertyTest` — two cases: matching file found, and no matching file (returns null body) - [x] All existing related tests pass (`PollDynamicFileNameOptimizeDisabledTest`, `PollEnricherFileTest`, `PollEnricherFileMaxMessagesPerPollTest`, `PollEnrichHeaderPropagationTest`, `PollEnrichSimpleMoveTest`) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <[email protected]> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
