You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "allthingssecurity (via GitHub)" <gi...@apache.org> on 2026/10/12 00:06:18 UTC
[PR] CAMEL-25549: camel-atom - Route sorted entries from the oldest to the newest one [camel]
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25549: camel-atom - sortEntries sorts by the updated date and routes the oldest entry first [camel]
Posted by "allthingssecurity (via GitHub)" <gi...@apache.org>.
allthingssecurity commented on PR #27696:
URL: https://github.com/apache/camel/pull/27696#issuecomment-6130240256
@davsclaus resolved again (5657957e3de2): only `camel-4x-upgrade-guide-4_24.adoc` conflicted, all sections of main are kept and this PR's section follows them; the code is unchanged. Each merge of one of these PRs makes the others conflict in that one file again; I re-resolve them within minutes of every merge.
_Claude Code on behalf of allthingssecurity_
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25549: camel-atom - sortEntries sorts by the updated date and routes the oldest entry first [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #27696:
URL: https://github.com/apache/camel/pull/27696#issuecomment-6129251220
Thanks — this is approved and green, but it now conflicts with `main` in `docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc` (other PRs added sections at the end of the same file). Could you rebase onto the latest `main` and keep both sections? It can be merged once CI is green again.
_Claude Code on behalf of @davsclaus._
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25549: camel-atom - sortEntries sorts by the updated date and routes the oldest entry first [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #27696:
URL: https://github.com/apache/camel/pull/27696#issuecomment-6130158096
@allthingssecurity merge conflict again
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25549: camel-atom - sortEntries sorts by the updated date and routes the oldest entry first [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #27696:
URL: https://github.com/apache/camel/pull/27696
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25549: camel-atom - sortEntries sorts by the updated date and routes the oldest entry first [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27696:
URL: https://github.com/apache/camel/pull/27696#issuecomment-6120428423
<!-- ci-tested-modules -->
:test_tube: **CI tested the following changed modules:**
- `catalog/camel-catalog`
- `components/camel-atom`
- `components/camel-rss`
- `docs`
- `dsl/camel-endpointdsl`
---
<details><summary>:microscope: Scalpel shadow comparison — Scalpel: 10 of 704 tested, 26 compile-only — current: 10 all tested</summary>
[Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **10 affected modules** (current approach: 10).
**Skip-tests mode would test 10 modules** (2 direct + 9 downstream), **skip tests for 26** (generated code, meta-modules)
<details><summary>Modules Scalpel would test (10)</summary>
- `camel-atom` ← components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java, components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntrySortTest.java
- `camel-jbang-mcp` ← downstream of org.apache.camel:camel-catalog
- `camel-jbang-plugin-mcp` ← downstream of org.apache.camel:camel-jbang-core
- `camel-jbang-plugin-route-parser` ← downstream of org.apache.camel:camel-route-parser
- `camel-jbang-plugin-tui` ← downstream of org.apache.camel:camel-catalog
- `camel-jbang-plugin-validate` ← downstream of org.apache.camel:camel-yaml-dsl-validator
- `camel-launcher-container` ← downstream of org.apache.camel:camel-launcher
- `camel-rss` ← downstream of org.apache.camel:camel-atom
- `camel-yaml-dsl-validator` ← downstream of org.apache.camel:camel-catalog
- `camel-yaml-dsl-validator-maven-plugin` ← downstream of org.apache.camel:camel-yaml-dsl-validator
</details>
<details><summary>Modules with tests skipped (26)</summary>
- `apache-camel`
- `camel-allcomponents`
- `camel-catalog`
- `camel-catalog-console`
- `camel-catalog-maven`
- `camel-catalog-suggest`
- `camel-componentdsl`
- `camel-endpointdsl`
- `camel-endpointdsl-support`
- `camel-itest`
- `camel-jbang-core`
- `camel-jbang-it`
- `camel-jbang-main`
- `camel-jbang-plugin-edit`
- `camel-jbang-plugin-generate`
- `camel-jbang-plugin-kubernetes`
- `camel-jbang-plugin-test`
- `camel-kamelet-main`
- `camel-launcher`
- `camel-report-maven-plugin`
- `camel-route-parser`
- `camel-yaml-dsl`
- `camel-yaml-dsl-deserializers`
- `camel-yaml-dsl-maven-plugin`
- `coverage`
- `dummy-component`
</details>
> :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
</details>
<details><summary>All tested modules (37 modules, 6m 23s total)</summary>
**Total reactor time:** 6m 23s
| Module | Duration | Status |
| --- | --- | --- |
| Camel :: Launcher | 48.2s | SUCCESS |
| Camel :: Atom | 42.4s | SUCCESS |
| Camel :: JBang :: MCP | 40.2s | SUCCESS |
| Camel :: Component DSL | 29.7s | SUCCESS |
| Camel :: RSS | 26.7s | SUCCESS |
| Camel :: YAML DSL :: Validator | 22.9s | SUCCESS |
| Camel :: Catalog :: Camel Catalog | 22.8s | SUCCESS |
| Camel :: YAML DSL | 19.6s | SUCCESS |
| Camel :: JBang :: Plugin :: Kubernetes | 19.1s | SUCCESS |
| Camel :: JBang :: Plugin :: Validate | 16.6s | SUCCESS |
| Camel :: Docs | 15.4s | SUCCESS |
| Camel :: Kamelet Main | 11.9s | SUCCESS |
| Camel :: JBang :: Plugin :: Testing | 11.5s | SUCCESS |
| Camel :: YAML DSL :: Deserializers | 8.2s | SUCCESS |
| Camel :: Catalog :: Camel Route Parser | 8.1s | SUCCESS |
| Camel :: Catalog :: Camel Report Maven Plugin | 6.8s | SUCCESS |
| Camel :: All Components Sync point | 5.2s | SUCCESS |
| Camel :: YAML DSL :: Validator Maven Plugin | 4.8s | SUCCESS |
| Camel :: YAML DSL :: Maven Plugins | 3.6s | SUCCESS |
| Camel :: Catalog :: Maven | 3.3s | SUCCESS |
| Camel :: Catalog :: Suggest (deprecated) | 2.2s | SUCCESS |
| Camel :: Assembly | 1.9s | SUCCESS |
| Camel :: JBang :: Integration tests | 1.6s | SUCCESS |
| Camel :: JBang :: Plugin :: MCP | 1.4s | SUCCESS |
| Camel :: JBang :: Plugin :: Edit | 1.4s | SUCCESS |
| Camel :: Coverage | 1.3s | SUCCESS |
| Camel :: Catalog :: Console | 1.3s | SUCCESS |
| Camel :: JBang :: Plugin :: Generate | 1.2s | SUCCESS |
| Camel :: Catalog :: Dummy Component | 1.1s | SUCCESS |
| Camel :: Endpoint DSL :: Support | 0.8s | SUCCESS |
| Camel :: JBang :: Main | 0.8s | SUCCESS |
| Camel :: Launcher :: Container | 0.7s | SUCCESS |
| Camel :: JBang :: Plugin :: Route Parser | 0.6s | SUCCESS |
| Camel :: Endpoint DSL | n/a | |
| Camel :: Integration Tests | n/a | |
| Camel :: JBang :: Core | n/a | |
| Camel :: JBang :: Plugin :: TUI | n/a | |
**Top 20 slowest modules:**
- `Camel :: Launcher` (48.2s)
- `Camel :: Atom` (42.4s)
- `Camel :: JBang :: MCP` (40.2s)
- `Camel :: Component DSL` (29.7s)
- `Camel :: RSS` (26.7s)
- `Camel :: YAML DSL :: Validator` (22.9s)
- `Camel :: Catalog :: Camel Catalog` (22.8s)
- `Camel :: YAML DSL` (19.6s)
- `Camel :: JBang :: Plugin :: Kubernetes` (19.1s)
- `Camel :: JBang :: Plugin :: Validate` (16.6s)
- `Camel :: Docs` (15.4s)
- `Camel :: Kamelet Main` (11.9s)
- `Camel :: JBang :: Plugin :: Testing` (11.5s)
- `Camel :: YAML DSL :: Deserializers` (8.2s)
- `Camel :: Catalog :: Camel Route Parser` (8.1s)
- `Camel :: Catalog :: Camel Report Maven Plugin` (6.8s)
- `Camel :: All Components Sync point` (5.2s)
- `Camel :: YAML DSL :: Validator Maven Plugin` (4.8s)
- `Camel :: YAML DSL :: Maven Plugins` (3.6s)
- `Camel :: Catalog :: Maven` (3.3s)
</details>
---
:gear: [View full build and test results](https://github.com/apache/camel/actions/runs/38186741731)
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25549: camel-atom - sortEntries sorts by the updated date and routes the oldest entry first [camel]
Posted by "allthingssecurity (via GitHub)" <gi...@apache.org>.
allthingssecurity commented on PR #27696:
URL: https://github.com/apache/camel/pull/27696#issuecomment-6121245078
Thanks. The upgrade-guide note is in `camel-4x-upgrade-guide-4_24.adoc` under `== Upgrading Camel 4.23 to 4.24` (72af70a97ef6; the file is created with the header of the 4_23 guide and added to `camel-4x-upgrade-guide.adoc`). I am watching the uncommitted-changes check for the generated `atom.json` / `rss.json` and endpoint DSL files and will fix them at once if it reports a difference.
_Claude Code on behalf of allthingssecurity_
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25549: camel-atom - Route sorted entries from the oldest to the newest one [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27696:
URL: https://github.com/apache/camel/pull/27696#issuecomment-6119629103
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: Apache Camel Committers, please review the following items:
* First-time contributors **require MANUAL approval** for the GitHub Actions to run
* You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
* You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
* Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
:warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25549: camel-atom - sortEntries sorts by the updated date and routes the oldest entry first [camel]
Posted by "allthingssecurity (via GitHub)" <gi...@apache.org>.
allthingssecurity commented on PR #27696:
URL: https://github.com/apache/camel/pull/27696#issuecomment-6129560812
Conflict resolved (548cff45aaf2, merged `main` into the branch): the only conflicting file was `camel-4x-upgrade-guide-4_24.adoc`, where other PRs had added sections; they are all kept and this PR's section follows them. The code is unchanged from the approved commits.
_Claude Code on behalf of allthingssecurity_
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25549: camel-atom - sortEntries sorts by the updated date and routes the oldest entry first [camel]
Posted by "allthingssecurity (via GitHub)" <gi...@apache.org>.
allthingssecurity commented on PR #27696:
URL: https://github.com/apache/camel/pull/27696#issuecomment-6131638360
Conflict in the 4.24 upgrade guide resolved again (02679192d136); the code is unchanged.
_Claude Code on behalf of allthingssecurity_
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25549: camel-atom - Route sorted entries from the oldest to the newest one [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #27696:
URL: https://github.com/apache/camel/pull/27696#discussion_r4245539257
##########
components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntrySortTest.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.atom;
+
+import java.time.ZonedDateTime;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.apptasticsoftware.rssreader.Item;
+import org.apache.camel.Consumer;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * With sortEntries the entries of a feed must be routed from the oldest to the newest one, as camel-rss does. The
+ * default idempotent strategy skips an entry that is older than the one routed before it, so any other order loses
+ * entries.
+ */
+@DisabledOnOs(OS.AIX)
+class AtomEntrySortTest extends CamelTestSupport {
+
+ // the feed has 10 entries, which are not in the order of their dates
+ private static final String FEED
+ = "atom:file:src/test/data/unsortedfeed.atom?splitEntries=true&throttleEntries=false&startScheduler=false";
+
+ @Test
+ void sortedEntriesAreAllRoutedOldestFirst() throws Exception {
+ List<ZonedDateTime> routed = pollOnce(FEED + "&sortEntries=true");
+
+ assertEquals(10, routed.size(), "All the entries of the feed must be routed");
+ assertEquals(sorted(routed), routed);
+ }
+
+ @Test
+ void sortedEntriesAreRoutedOldestFirstWithoutIdempotency() throws Exception {
+ List<ZonedDateTime> routed = pollOnce(FEED + "&sortEntries=true&idempotent=false");
+
+ assertEquals(10, routed.size());
+ assertEquals(sorted(routed), routed);
+ }
+
+ @Test
+ void entriesAreAllRoutedWithoutSortEntries() throws Exception {
+ List<ZonedDateTime> routed = pollOnce(FEED);
+
+ assertEquals(10, routed.size());
+ assertEquals(sorted(routed), routed);
+ }
+
+ /**
+ * Runs one poll of a consumer of the given endpoint (its scheduler is not started) and returns the dates of the
+ * routed entries.
+ */
+ private List<ZonedDateTime> pollOnce(String uri) throws Exception {
+ List<ZonedDateTime> routed = new ArrayList<>();
+ Consumer consumer = context.getEndpoint(uri).createConsumer(
+ exchange -> routed.add(exchange.getIn().getBody(Item.class).getUpdatedZonedDateTime().orElseThrow()));
Review Comment:
`Item.getUpdatedZonedDateTime()` is `@Deprecated(since = "3.12.0", forRemoval = true)` in rssreader 3.12.0; please use `getUpdatedAsZonedDateTime()` instead.
##########
components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java:
##########
@@ -67,6 +69,12 @@ private List<Item> readItems() throws IOException {
if (items == null) {
items = AtomUtils.readItems(getEndpoint().getCamelContext(), getEndpoint().getFeedUri(), rssReader,
getEndpoint().isSortEntries());
+ if (getEndpoint().isSortEntries()) {
+ // sorted entries have the oldest entry first, but the entries are routed from the end of the list
+ // (without sortEntries the newest entry is first): reverse them, so the oldest entry is routed first
Review Comment:
After this reverse the result is the same order as without `sortEntries` (the default `naturalOrder()` is `newestPublishedItemFirst()`, the exact reverse of `oldestPublishedItemFirst()`). So `sortEntries` becomes a no-op for the split consumer. Would you consider sorting by the updated date here (like 3.x did and like the idempotent strategy uses), e.g. `ItemComparator.newestUpdatedItemFirst()`?
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25549: camel-atom - sortEntries sorts by the updated date and routes the oldest entry first [camel]
Posted by "allthingssecurity (via GitHub)" <gi...@apache.org>.
allthingssecurity commented on code in PR #27696:
URL: https://github.com/apache/camel/pull/27696#discussion_r4245780790
##########
components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java:
##########
@@ -67,6 +69,12 @@ private List<Item> readItems() throws IOException {
if (items == null) {
items = AtomUtils.readItems(getEndpoint().getCamelContext(), getEndpoint().getFeedUri(), rssReader,
getEndpoint().isSortEntries());
+ if (getEndpoint().isSortEntries()) {
+ // sorted entries have the oldest entry first, but the entries are routed from the end of the list
+ // (without sortEntries the newest entry is first): reverse them, so the oldest entry is routed first
Review Comment:
You are right. The natural order of `Item` is `ItemComparator.newestPublishedItemFirst()` (rssreader 3.12.0), so
the reversed list was the order of the default and `sortEntries` did nothing for the split consumer.
Changed in edbcc7bf9a19 as you suggest: with `sortEntries=true` the consumer sorts with
`ItemComparator.newestUpdatedItemFirst()` (AtomEntryPollingConsumer.java:77) and the loop routes from the end, so
the oldest updated entry is routed first. That comparator already falls back to the published date for an entry
without an updated date, which is the same date `ItemUpdatedIdempotentStrategy` compares. I checked the two
references: 3.22.x has `feed.sortEntriesByUpdated(true)` and its `AtomEntrySortTest` expects ascending updated
dates, and camel-rss sorts with `RssDateComparator` (updated, else published) and routes the oldest first.
New test data `edited-feed.atom`: four entries published in the order first to fourth, the first one updated after
all the others, the third without an updated date. Expected: `second, third, fourth, first`.
- main: `[fourth, first]` is routed, second and third are lost.
- previous head (bb9f3fad5c4c): `[first]` is routed, the three newer entries are skipped.
- now: all four, in that order, also with `idempotent=false`.
Not changed: `AtomUtils.readItems`, so the list of a consumer with `splitEntries=false` is as before (published
date, oldest first), and camel-rss. The description of the option (`FeedEndpoint`, shared with camel-rss) said "by
published date"; it now names the updated date with the published date as fallback.
_Claude Code on behalf of allthingssecurity_
##########
components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntrySortTest.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.atom;
+
+import java.time.ZonedDateTime;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.apptasticsoftware.rssreader.Item;
+import org.apache.camel.Consumer;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * With sortEntries the entries of a feed must be routed from the oldest to the newest one, as camel-rss does. The
+ * default idempotent strategy skips an entry that is older than the one routed before it, so any other order loses
+ * entries.
+ */
+@DisabledOnOs(OS.AIX)
+class AtomEntrySortTest extends CamelTestSupport {
+
+ // the feed has 10 entries, which are not in the order of their dates
+ private static final String FEED
+ = "atom:file:src/test/data/unsortedfeed.atom?splitEntries=true&throttleEntries=false&startScheduler=false";
+
+ @Test
+ void sortedEntriesAreAllRoutedOldestFirst() throws Exception {
+ List<ZonedDateTime> routed = pollOnce(FEED + "&sortEntries=true");
+
+ assertEquals(10, routed.size(), "All the entries of the feed must be routed");
+ assertEquals(sorted(routed), routed);
+ }
+
+ @Test
+ void sortedEntriesAreRoutedOldestFirstWithoutIdempotency() throws Exception {
+ List<ZonedDateTime> routed = pollOnce(FEED + "&sortEntries=true&idempotent=false");
+
+ assertEquals(10, routed.size());
+ assertEquals(sorted(routed), routed);
+ }
+
+ @Test
+ void entriesAreAllRoutedWithoutSortEntries() throws Exception {
+ List<ZonedDateTime> routed = pollOnce(FEED);
+
+ assertEquals(10, routed.size());
+ assertEquals(sorted(routed), routed);
+ }
+
+ /**
+ * Runs one poll of a consumer of the given endpoint (its scheduler is not started) and returns the dates of the
+ * routed entries.
+ */
+ private List<ZonedDateTime> pollOnce(String uri) throws Exception {
+ List<ZonedDateTime> routed = new ArrayList<>();
+ Consumer consumer = context.getEndpoint(uri).createConsumer(
+ exchange -> routed.add(exchange.getIn().getBody(Item.class).getUpdatedZonedDateTime().orElseThrow()));
Review Comment:
Done in edbcc7bf9a19: the test uses `getUpdatedAsZonedDateTime()` (it is in rssreader 3.12.0, the version of the
build).
_Claude Code on behalf of allthingssecurity_
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25549: camel-atom - sortEntries sorts by the updated date and routes the oldest entry first [camel]
Posted by "allthingssecurity (via GitHub)" <gi...@apache.org>.
allthingssecurity commented on PR #27696:
URL: https://github.com/apache/camel/pull/27696#issuecomment-6120121576
Pushed edbcc7bf9a19 on top (no force-push).
- `sortEntries=true` now sorts by the updated date, falling back to the published date, and routes the oldest entry
first; see the inline reply for the test with an older post that was edited recently (fails on main and with the
previous head).
- Upgrade guide: "(Breaking change)" is removed. The note describes a fix, names the sort key and says what routes
with `idempotent=false` get. Heading: `=== camel-atom - sortEntries sorts by the updated date and routes the oldest
entry first`.
- The PR title and description are updated to this.
- The option description changed, so `atom.json` / `rss.json` (component and catalog) and the javadoc of
`AtomEndpointBuilderFactory` / `RssEndpointBuilderFactory` changed with it. I could not run the catalog and
endpoint DSL generators here (they need every component built): the catalog files are copies of the regenerated
component files, and the DSL javadoc is rewrapped with the rule of `EndpointDslMojo`. If CI reports uncommitted
generated changes I will fix them.
Tests: `AtomEntrySortTest` 5 tests (4 fail on main, 2 with the previous head); camel-atom 38, 0 failures, 1 skipped
(as on main); camel-rss 19, 0 failures, 2 skipped.
_Claude Code on behalf of allthingssecurity_
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25549: camel-atom - sortEntries sorts by the updated date and routes the oldest entry first [camel]
Posted by "allthingssecurity (via GitHub)" <gi...@apache.org>.
allthingssecurity commented on PR #27696:
URL: https://github.com/apache/camel/pull/27696#issuecomment-6125049457
Rebased on `main` (78b557e8b492): the 4.24 upgrade guide is on main now, so the only conflict was that file, and this PR's section is kept after the existing one. The code is unchanged from the reviewed commits.
_Claude Code on behalf of allthingssecurity_
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org