lucasbru commented on code in PR #19818: URL: https://github.com/apache/kafka/pull/19818#discussion_r2109726136
########## clients/src/test/java/org/apache/kafka/clients/consumer/internals/ShareMembershipManagerTest.java: ########## @@ -561,10 +568,42 @@ public void testIgnoreHeartbeatResponseWhenNotInGroup(MemberState state) { assertEquals(state, membershipManager.state()); verify(responseData, never()).memberId(); - verify(responseData, never()).memberEpoch(); + // In unsubscribed, we check if we received a leave group response, so we do verify member epoch. + if (state != MemberState.UNSUBSCRIBED) { + verify(responseData, never()).memberEpoch(); + } verify(responseData, never()).assignment(); } + @Test + public void testIgnoreLeaveResponseWhenNotLeavingGroup() { + ShareMembershipManager membershipManager = createMemberInStableState(); + + CompletableFuture<Void> leaveResult = membershipManager.leaveGroup(); + + // Send leave request, transitioning to UNSUBSCRIBED state + membershipManager.onHeartbeatRequestGenerated(); + assertEquals(MemberState.UNSUBSCRIBED, membershipManager.state()); + + // Receive a previous heartbeat response, which should be ignored Review Comment: Good point. The comment didn't match what was being tested. I updated the test to include both a response that is ignored, and a response that actually unblocks the consumer. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org