allthingssecurity commented on PR #30001:
URL: https://github.com/apache/camel/pull/30001#issuecomment-6892008046
Thanks for the careful read of the two `done()` methods (`SentCallback` in
`SendProcessor` and `SyncSend` in `DefaultProducerCache`). I looked at the
window, and I think it is benign as written, so I left the order as it is:
- When the CAS is won on the **same** thread that later reaches the catch
(the producer called the callback, then threw), the write of `doneSync` happens
before the throw in program order, so the catch reads the real value.
- When the CAS is won on **another** thread, the callback came
asynchronously, so the right answer for the catch is `false` ("the exchange
goes on through the callback"), and that is also the default the catch can read
before the other thread's write. The only other case is a producer that calls
`done(true)` from another thread, which already breaks the contract. There,
reading `false` is the safer outcome, because the exchange then goes on once,
through the callback. Returning `true` would let the caller go on too.
- Writing `doneSync` before the CAS, as suggested, would let a second
`done()` call (the contract-breaking case these classes exist for) overwrite
the value of the first one after the catch read it. So the current order is the
one I would keep.
Happy to add a short comment saying this next to both fields if that helps
the next reader.
_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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]