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

   # Description
   
   [CAMEL-26965](https://issues.apache.org/jira/browse/CAMEL-26965). Found by 
rule R3 of the exchange sanitizer 
([CAMEL-26630](https://issues.apache.org/jira/browse/CAMEL-26630)), whose first 
part (the `AsyncProcessor` contract: `process` returns the value its callback 
is called with) is the next sanitizer PR. That PR is meant to merge after this 
one.
   
   `InterceptSendToEndpointProcessor` returned the value of the `before` of the 
interceptor and called the callback with the value of what ran after it, the 
producer of the original endpoint or the `after` processor (`afterBefore`: 
`callback.done(doneSync1)`, and the return of the rest of the chain was 
dropped):
   
   - `interceptSendToEndpoint(...)`: the `before` is a route, which goes on 
through the reactive executor and returns `false`; with a synchronous producer 
such as `mock`, the callback came with `true`. The same shape was there before 
CAMEL-25140.
   - advice with `mockEndpoints()` (not skip): the `before` is the producer of 
a mock, which returns `true`; with an asynchronous producer, `process` returned 
`true` and the producer's thread called the callback with `false` later.
   
   The callers of a step in Camel go on through the callback, so the routes 
work today. A caller that uses the return value, as the Javadoc of 
`AsyncProcessor` allows, continues the exchange twice in the second case, or 
not at all in the first. In Camel the routing slip reads both; a routing slip 
through an intercepted endpoint goes on before and after this change (a test 
pins it), so this is about the contract, not a hang I could reproduce.
   
   ## The fix
   
   The callback now gets `false` when the `before` or anything after it was 
asynchronous (`doneSync && doneSync1`, and the value of the `after` combined 
the same way), and `process` returns the value of the whole chain when the 
`before` was done on the calling thread (`sync && rest`). The value of the rest 
is read only when the `before` returned `true`, that is, after its callback ran 
on this thread. Nothing else changes: the same steps run in the same order, and 
only the two values change where they disagreed.
   
   ## Tests
   
   `InterceptSendToEndpointDoneSyncTest` calls the producer of an intercepted 
endpoint directly and compares the return value with the value of the callback: 
an `interceptSendToEndpoint` before a `mock`, and a mock producer as the before 
of an endpoint whose producer calls back on its own thread. Both fail on main 
(`expected: <false> but was: <true>`, and `<true> but was: <false>`); the other 
two tests, the route itself and a routing slip through the intercepted 
endpoint, pass on both. The whole camel-core suite passes on this commit (9343 
tests, 0 failures; the 11 errors are the `DumpModel*` tests, which fail the 
same way on main here because of a stale `camel-yaml-io` in my local 
repository). With the R3 sanitizer branch and the CI switch (`-Psanitizer`), 
the 16 test classes it reported for this processor (37 reports) pass.
   
   # 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): 
[CAMEL-26965](https://issues.apache.org/jira/browse/CAMEL-26965).
   
   # 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 the core modules and the base components with the formatter and 
import-sort plugins; no generated file changes. 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