Skip to content

Fix[TcpBrokerConnection]: desync of bmqEvents - #91

Open
678098 wants to merge 1 commit into
bloomberg:mainfrom
678098:260724_desync_bmqEvents
Open

Fix[TcpBrokerConnection]: desync of bmqEvents#91
678098 wants to merge 1 commit into
bloomberg:mainfrom
678098:260724_desync_bmqEvents

Conversation

@678098

@678098 678098 commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Problem

handleAuthenticationResponse() and handleNegotiationResponse() early-return when their timeout future isDone() before polling bmqEvents. But the triggering event was already put() onto the queue in addBmqEvent(), so it is never drained. This desyncs the queue (off-by-one): a subsequent BlazingMQ event during NEGOTIATING/AUTHENTICATING then polls the stale event instead of the current one, causing it to be misread. cancel() also sets isDone(), so this can trigger when a second event arrives right after the first is processed.

Fix

Reorder both handlers to poll bmqEvents first, then check the timeout. The triggering event is always drained regardless of timeout state.

Tests

Added two regression tests in TcpBrokerConnectionReauthTest (testNegotiationResponseDrainsEventWhenTimeoutDone, testAuthenticationResponseDrainsEventWhenTimeoutDone) that assert the handler drains its triggering event when the timeout future is already done.

@678098
678098 requested a review from pniedzielski July 24, 2026 18:30
@678098
678098 force-pushed the 260724_desync_bmqEvents branch from 15c19c3 to 2544b55 Compare July 24, 2026 20:06
Signed-off-by: Evgeny Malygin <emalygin@bloomberg.net>
@678098
678098 force-pushed the 260724_desync_bmqEvents branch from 2544b55 to 8f828fe Compare July 24, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants