kirktrue commented on code in PR #15723: URL: https://github.com/apache/kafka/pull/15723#discussion_r1579862658
########## clients/src/test/java/org/apache/kafka/clients/consumer/internals/RequestStateTest.java: ########## @@ -48,4 +50,40 @@ public void testRequestStateSimple() { state.reset(); assertTrue(state.canSendRequest(200)); } + + @Test + public void testTrackInflightOnSuccessfulAttempt() { + testTrackInflight(RequestState::onSuccessfulAttempt); + } + + @Test + public void testTrackInflightOnFailedAttempt() { + testTrackInflight(RequestState::onFailedAttempt); + } + + private void testTrackInflight(BiConsumer<RequestState, Integer> onCompletedAttempt) { + RequestState state = new RequestState( + new LogContext(), + this.getClass().getSimpleName(), + 100, + 2, + 1000, + 0); + + // This is just being paranoid... + assertFalse(state.requestInFlight()); + + // When we've sent a request, the flag should update from false to true. + state.onSendAttempt(); + assertTrue(state.requestInFlight()); + + // Now we've received the response. + onCompletedAttempt.accept(state, 236); + + // When we've sent a second request with THE SAME TIMESTAMP as the previous response, Review Comment: I added back the timestamp so we could use it in the `lastSentMs` value for debugging. So the comment should make sense again. -- 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