ableegoldman commented on a change in pull request #11111:
URL: https://github.com/apache/kafka/pull/11111#discussion_r675241237



##########
File path: 
clients/src/main/java/org/apache/kafka/clients/NetworkClientUtils.java
##########
@@ -60,17 +60,16 @@ public static boolean awaitReady(KafkaClient client, Node 
node, Time time, long
             throw new IllegalArgumentException("Timeout needs to be greater 
than 0");
         }
         long startTime = time.milliseconds();
-        long expiryTime = startTime + timeoutMs;
 
         if (isReady(client, node, startTime) ||  client.ready(node, startTime))
             return true;
 
         long attemptStartTime = time.milliseconds();
-        while (!client.isReady(node, attemptStartTime) && attemptStartTime < 
expiryTime) {
+        while (!client.isReady(node, attemptStartTime) && attemptStartTime - 
startTime < timeoutMs) {
             if (client.connectionFailed(node)) {
                 throw new IOException("Connection to " + node + " failed.");
             }
-            long pollTimeout = expiryTime - attemptStartTime;
+            long pollTimeout = (startTime - attemptStartTime) + timeoutMs;

Review comment:
       The `startTime` is set once at the beginning of the method while the 
`attemptStartTime` is initialized just before the first attempt and then 
updated again after every iteration. So the `attemptStartTime` is always 
greater than the `startTime` and therefore the quantity being added to the 
`timeoutMs` here is actually negative. 
   
   But I see how that's confusing, I'll refactor the expression to make this 
more clear




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