anmolnar commented on code in PR #1782:
URL: https://github.com/apache/zookeeper/pull/1782#discussion_r2021746008


##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Learner.java:
##########
@@ -410,8 +410,12 @@ private Socket connectToLeader() throws IOException, 
X509Exception, InterruptedE
             int remainingTimeout;
             long startNanoTime = nanoTime();
 
-            for (int tries = 0; tries < 5 && socket.get() == null; tries++) {
+            for (int tries = 0; tries < 5; tries++) {
                 try {
+                    sock = createSocket();
+                    if (socket.get() == null) {
+                        continue;

Review Comment:
   I don't understand this either. Wouldn't be better to use the try block for 
creating and closing?
   ```java
   try (Socket sock = createSocket())  {
   ...
   }
   ```



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