gnodet commented on PR #24448: URL: https://github.com/apache/camel/pull/24448#issuecomment-4891898469
### Third commit: Fix race condition in BackpressureStrategyTest Investigation revealed a pre-existing race condition in `BackpressureStrategyTest` that caused the exact-sum assertions to fail non-deterministically (even without `Thread.sleep`). **Root cause**: `CamelSubscription.checkAndFlush()` schedules the flush asynchronously on a worker pool thread. With the timer firing every 20ms, the next item can arrive and modify the buffer (via the backpressure strategy) before the flush actually runs: - **OLDEST**: Item 1 enters buffer → Item 2 arrives before flush → OLDEST discards item 2 (keeps oldest) → flush delivers item 1 → item 3 becomes the new oldest → result: [1, 3] sum=4 instead of [1, 2] sum=3 - **LATEST**: Item 1 enters buffer → Item 2 arrives before flush → LATEST replaces item 1 with item 2 → flush delivers item 2 → item 20 ends up as latest → result: [2, 20] sum=22 instead of [1, 20] sum=21 **Fix**: Replace fragile exact-sum assertions with invariant-based assertions that verify the actual backpressure strategy behavior: - **OLDEST**: first item is always 1 (oldest kept in buffer), second item is an early value (>1, <20) - **LATEST**: second item is always 20 (most recent always kept by LATEST strategy) _Claude Code on behalf of Guillaume Nodet_ -- 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]
