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

   # Description
   
   [CAMEL-24947](https://issues.apache.org/jira/browse/CAMEL-24947)
   
   With request/reply and `timeout > 0`, `SedaProducer`'s reply path (`onDone`: 
latch check, then `copyResults`, then `countDown`) was not atomic with the 
timeout path. A reply arriving at the timeout could be copied into the caller's 
exchange after the producer had already returned `ExchangeTimedOutException`. 
The caller could then see the reply body together with the exception, and its 
exchange could still change after the producer returned. In a stress run, 24 of 
400 near-timeout requests came back inconsistent and 2 were modified after 
return.
   
   This change: the reply and the timeout claim the exchange with a 
compare-and-set on a shared `AtomicBoolean`. A late reply that loses is 
ignored. If the timeout loses because the reply is already being copied, the 
producer waits for that short copy to finish and returns the reply instead of 
the timeout.
   
   Tests: new `SedaTimeoutLateReplyTest` (2 tests) pauses the consumer inside 
the reply copy with a `SafeCopyProperty`, so there are no sleeps. Without the 
fix it fails with "Producer returned while the reply was copied into the 
exchange". `*Seda*`: 133 tests, 0 failures.
   
   Note: if this and #PR_31 (CAMEL-24948) are both merged, the interrupted 
reply wait from CAMEL-24948 has to claim the exchange with the same 
compare-and-set. Git merges the two without a conflict, but that combination 
needs one small follow-up change, which I'll send once the first of them is 
merged.
   
   Found with a TLA+ model of SedaProducer/SedaConsumer, then reproduced 
against the real classes.
   
   # 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 the affected modules, 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.
   


-- 
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