allthingssecurity commented on PR #27470:
URL: https://github.com/apache/camel/pull/27470#issuecomment-6033226491

   Thanks @davsclaus. I checked the follow-up on `main` (fb86fbed28dc) and you 
are right. It happens even without a race: the completion branch of 
`checkAndFlush()` discards the live buffer without clearing it, so a subscriber 
that calls `cancel()` after `onComplete` makes `cancel()` discard the same 
exchanges again. In a quick unit test on `CamelSubscription` (two buffered 
exchanges, `signalCompletion()` then `cancel()`), the callbacks run 4 times 
instead of 2. For the producer that means `callback.done(false)` twice.
   
   It is limited in practice: `signalCompletion()` is only called from 
`CamelPublisher.close()`, and `DefaultCamelReactiveStreamsService` never closes 
its publishers. The fix would be to copy and clear the buffer under the mutex 
in that branch, as `cancel()` does. I'll keep it out of this PR and propose a 
separate ticket for it.
   
   _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]

Reply via email to