GH-4444: Fix COUNT_TIME ack mode ignoring the time condition#1
Merged
Conversation
…dition For COUNT_TIME mode, both isCountAck and isTimeAck are true. The previous if-else-if structure caused timedAcks() to be unreachable whenever isCountAck was true, so the time threshold was never checked. Split into independent if blocks so both countAcks() and timedAcks() run for COUNT_TIME. Double-commit is not possible: when countAcks() fires it resets `last` to now, so the subsequent timedAcks() call sees elapsed ≈ 0 and does not commit again. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: sandeep erelli <sandeep.erelli@hotmail.com>
Verifies that ackTime-based commits fire for COUNT_TIME mode even when ackCount has not been reached (the scenario broken before the fix). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: sandeep erelli <sandeep.erelli@hotmail.com>
ef10481 to
24cc5ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes spring-projects#4444.
In
KafkaMessageListenerContainer.processCommits(), theif-else ifstructure causedtimedAcks()to be unreachable forCOUNT_TIMEack mode:For
COUNT_TIME, bothisCountAckandisTimeAckaretrue, sotimedAcks()was never reached — only the count threshold was ever checked.Fix
Split into two independent
ifchecks so both conditions are evaluated:No double-commit risk: when
countAcks()fires it resetslast = now, so the subsequenttimedAcks()call seeselapsed ≈ 0and skips the commit.Tests
Added
testCountTimeAckModeCommitsOnTimeExpiry— a mock-based test that sets a largeackCount(1000, never reached) and a smallackTime(300 ms), then asserts thatcommitSyncis called within 10 s purely from the time condition being satisfied.🤖 Generated with Claude Code