frankvicky commented on code in PR #16844:
URL: https://github.com/apache/kafka/pull/16844#discussion_r1732103865


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/HeartbeatRequestManagerTest.java:
##########
@@ -380,6 +381,30 @@ public void testNetworkTimeout() {
         assertEquals(1, result.unsentRequests.size());
     }
 
+    @Test
+    public void testDisconnect() {
+        // The initial heartbeatInterval is set to 0
+        createHeartbeatRequestStateWithZeroHeartbeatInterval();
+        NetworkClientDelegate.PollResult result = 
heartbeatRequestManager.poll(time.milliseconds());
+        assertEquals(1, result.unsentRequests.size());
+        // Mimic disconnect
+        result.unsentRequests.get(0).handler().onFailure(time.milliseconds(), 
DisconnectException.INSTANCE);
+        verify(membershipManager).onHeartbeatFailure(true);
+        // Ensure that the coordinatorManager rediscovers the coordinator
+        verify(coordinatorRequestManager).markCoordinatorUnknown(any(), 
anyLong());
+        verify(backgroundEventHandler, never()).add(any());
+
+        // Assure the manager will backoff on disconnect

Review Comment:
   Cool, this way we can provide stronger protection for our code. 👍🏼 



-- 
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