allthingssecurity opened a new pull request, #27920:
URL: https://github.com/apache/camel/pull/27920

   # Description
   
   [CAMEL-25681](https://issues.apache.org/jira/browse/CAMEL-25681)
   
   `FileIdempotentRepository.add(key)` put the key into its 1st-level cache 
first, and then checked the file store (`containsStore`) and appended the key 
to it (`appendToStore`). When the store could not be read or written (disk 
full, permissions, an I/O error of a network file system), `add` threw and the 
message failed, but the key stayed in the cache. Every later `add` of that key 
returned `false` from the cache until the application was restarted.
   
   So the retry of the failed message was taken for a duplicate and skipped, 
also after the store worked again. For example an `idempotentConsumer` with a 
file repository behind a JMS consumer: during a "disk full" period every 
message fails, the broker redelivers them, and the redeliveries are filtered as 
duplicates and acknowledged.
   
   `KafkaIdempotentRepository.add` (camel-kafka, lines 352-363 on main) already 
takes the key out of its cache again when storing it fails. The other 
repositories in the project have no cache in front of their store.
   
   Change: the key is put into the cache only after it was found in the store 
or appended to it. The store is accessed in the same order as before, and a key 
found in the store is still cached (CAMEL-12148: the cache is only a quick 
lookup). A store that works gives the same results as before, so there is no 
upgrade guide entry.
   
   Tests:
   - New `FileIdempotentRepositoryFailedStoreTest` (camel-support, 3 tests):
     - `appendToStore` fails once ("No space left on device"), then works: 
adding the key again must return `true`, a third add `false`, and the store 
must hold the key once;
     - the store cannot be read (a directory took its place), then it can: 
adding the key again must return `true`;
     - a key that another repository wrote to the store is found and cached. 
This one passes on main too; it pins the cache registration that the change 
moved.
   - Without the change the first two fail: `[the retry of a key that was not 
stored] Expecting value to be true but was false`.
   - With the change: camel-support tests 136 run, 0 failures; camel-core tests 
matching `*Idempotent*` 77 run, 0 failures.
   
   What is not changed:
   - When `trunkStore` (the store reached its maximum size) fails after the key 
was appended, `add` still throws although the key is stored, so the retry is a 
duplicate.
   - `remove` removes the key from the cache before the store; when the store 
fails the key stays in the file, and `contains` still answers `true` from the 
file.
   
   What was not run: the full camel-core test suite (only the idempotent 
tests), camel-main and camel-management tests.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [ ] 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).
     (The ticket is drafted and not filed yet; CAMEL-25681 is a placeholder 
until it is.)
   
   # 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-support and camel-core, 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]

Reply via email to