ShivsundarR commented on code in PR #19886:
URL: https://github.com/apache/kafka/pull/19886#discussion_r2536839741
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/NetworkClientDelegateTest.java:
##########
@@ -282,6 +283,51 @@ public void testRecordUnsentRequestsQueueTime(String
groupName) throws Exception
}
}
+ @Test
+ public void testPollWithOnClose() throws Exception {
+ try (NetworkClientDelegate ncd = newNetworkClientDelegate(false)) {
+ NetworkClientDelegate.UnsentRequest unsentRequest =
newUnsentFindCoordinatorRequest();
+ ncd.add(unsentRequest);
+
+ // First poll without onClose
+ ncd.poll(0, time.milliseconds());
+ assertTrue(ncd.hasAnyPendingRequests());
+
+ // Poll with onClose=true
+ ncd.poll(0, time.milliseconds(), true);
+ assertTrue(ncd.hasAnyPendingRequests());
+
+ // Complete the request
+
client.respond(FindCoordinatorResponse.prepareResponse(Errors.NONE, GROUP_ID,
mockNode()));
+ ncd.poll(0, time.milliseconds(), true);
+ assertFalse(ncd.hasAnyPendingRequests());
+ }
+ }
+
+ @Test
+ public void testCheckDisconnectsWithOnClose() throws Exception {
+ try (NetworkClientDelegate ncd = newNetworkClientDelegate(false)) {
+ NetworkClientDelegate.UnsentRequest unsentRequest =
newUnsentFindCoordinatorRequest();
+ ncd.add(unsentRequest);
+
+ // Mark node as disconnected
+ Node node = mockNode();
+ client.setUnreachable(node, REQUEST_TIMEOUT_MS);
+
+ // Poll with onClose=false
+ ncd.poll(0, time.milliseconds(), false);
Review Comment:
Thanks, that makes sense. I have updated the test now.
--
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]