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


##########
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:
   nit: what about we add an assertion msg instead of an inline comment? I find 
the code would be cleaner, and this would be more helpful if ever the test 
fails: `assertEquals(0, result.unsentRequests.size(), "No request should be 
generated before the backoff expires");`



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