[
https://issues.apache.org/jira/browse/CAMEL-25290?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-25290:
--------------------------------
Fix Version/s: 4.23.0
> camel-couchdb - the consumer ignores updates=false, and stops seeing changes
> for good after a page of changes that deletes=false or updates=false skips
> -------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-25290
> URL: https://issues.apache.org/jira/browse/CAMEL-25290
> Project: Camel
> Issue Type: Bug
> Components: camel-couchdb
> Reporter: shashank
> Priority: Major
> Fix For: 4.23.0
>
>
> {{CouchDbConsumer.poll}} filters the changes of the {{_changes}} feed like
> this:
> {code:java}
> if (changesResultItem.isDeleted() != null) {
> if (changesResultItem.isDeleted() && !endpoint.isDeletes()) {
> continue;
> }
> if (!changesResultItem.isDeleted() && !endpoint.isUpdates()) {
> continue;
> }
> }
> lastSequence = changesResultItem.getSeq();
> ...
> } finally {
> // Update since with latest seq, the messages are ordered
> since = changesResultItem.getSeq();
> }
> {code}
> h3. 1. updates=false is ignored
> CouchDB sets {{"deleted": true}} only on the changes of deleted documents;
> the change of an insert or update has no {{deleted}} field, so
> {{ChangesResultItem.isDeleted()}} is {{null}} and the filters are not
> applied. With {{updates=false}} every insert and update is still published
> (with the {{UPDATE}} method header).
> h3. 2. Skipped changes do not move "since"
> A change skipped with {{continue}} does not advance {{since}}. The consumer
> asks for {{limit=maxMessagesPerPoll}} (10 by default) changes after
> {{since}}; when a whole page is skipped, for example after deleting 10
> documents on an endpoint with {{deletes=false}}, every poll gets the same
> page again and the consumer never sees a later change. The route stays
> started; nothing is logged.
> Both are regressions of CAMEL-20800 (4.7.0). Before, the consumer used
> LightCouch, whose {{ChangesResult.Row.isDeleted()}} is a primitive
> {{boolean}} ({{false}} for inserts and updates), and a continuous changes
> feed that never asked for the same changes again. Fixing only case 1 would
> make case 2 more likely (a page of 10 updates with {{updates=false}} would
> also stall), so both are fixed together.
> h3. Reproduction
> {{CouchDbConsumerFilterTest}} (new, mocked {{CouchDbClientWrapper}}, the
> changes are parsed from JSON with the Cloudant SDK's Gson):
> * {{testDeletesFalseMovesPastDeletedDocuments}}: a page of 3 deleted
> documents, {{deletes=false}}, two polls. On main the second poll asks again
> with {{since=0}} instead of the last sequence.
> * {{testUpdatesFalseSkipsUpdatedDocuments}}: one update and one delete,
> {{updates=false}}. On main {{expected: <1> but was: <2>}}.
> * {{testDefaultPublishesUpdatesAndDeletes}}: control, passes on main.
> h3. Proposed fix
> A missing {{deleted}} means not deleted, and a skipped change moves {{since}}
> past it like a processed one. With the fix the 3 tests pass, and the module
> suite passes (16 unit tests; the IT needs Docker). The IT {{CouchDbCrudIT}}
> does not catch case 1 because it resets the delete mock before the delete.
> Not in scope: since CAMEL-20800 {{CouchDbClientWrapper.pollChanges}} ignores
> the {{style}} and {{heartbeat}} options (a plain, non-continuous {{_changes}}
> request per poll); a separate issue.
> Affected: 4.7.0 and later: 4.14.x, 4.18.x and main (same code since
> CAMEL-20800).
> Duplicate check (2026-10-03): JIRA text "couchdb" since 2023 (10 issues:
> CAMEL-20800, 23524, ...): none about the consumer filters or "since". GitHub
> pull requests "couchdb": only dependency and container upgrades.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)