allthingssecurity opened a new pull request, #27696: URL: https://github.com/apache/camel/pull/27696
# Description [CAMEL-25549](https://issues.apache.org/jira/browse/CAMEL-25549) With `sortEntries=true`, `AtomUtils.readItems` sorts the items of a feed oldest first, but `FeedEntryPollingConsumer.poll` routes the entries from the end of the list, so they were routed from the newest to the oldest one. camel-rss sorts newest first for the same loop and routes oldest first (`RssEntrySortTest`), and so did camel-atom up to 3.x (its `AtomEntrySortTest` was removed when the parser was replaced in 4.0, CAMEL-19063). Since 4.21 the consumer is idempotent by default (CAMEL-23220): `ItemUpdatedIdempotentStrategy` routes an entry only when its date is after the date of the entry routed before it. With the newest entry routed first, every other entry is older and is skipped, so `atom:...?sortEntries=true` routed one entry of a feed and silently skipped the others. Now `AtomEntryPollingConsumer` reverses the sorted list, so the loop routes the oldest entry first and the idempotent strategy accepts every entry. `AtomUtils.readItems`, and the list a consumer with `splitEntries=false` puts in the body, are unchanged. Routes with `sortEntries=true&idempotent=false` now get the entries in the reverse order (oldest first, where they were routed newest first), so the note in the 4.23 upgrade guide is marked "(Breaking change)" and says so. Tests: - New `AtomEntrySortTest`: one poll of `unsortedfeed.atom` (10 entries), the consumer polled directly (`startScheduler=false`), with `sortEntries=true`, with `sortEntries=true&idempotent=false`, and without `sortEntries`. - On main the first two fail: `sortedEntriesAreAllRoutedOldestFirst` with `All the entries of the feed must be routed ==> expected: <10> but was: <1>`, and `sortedEntriesAreRoutedOldestFirstWithoutIdempotency` because the dates are in descending order. The third, `entriesAreAllRoutedWithoutSortEntries`, passes on main too: without `sortEntries` the order was already oldest first, and the change does not touch that path. - With the change: camel-atom 36 tests, 0 failures, 1 skipped (as on main). Found with a Lean 4 model of the poll (an entry as its date, the idempotent strategy as "keep an entry after the last kept date"): for every sorted feed main routes only the newest entry; the fix routes every entry, in order. I then reproduced it with the consumer. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built and tested camel-atom, including the formatter and import-sort plugins. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
