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


##########
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:
   @anmolnar oh you're right. try block for creating and closing is better.
   
   @kezhuw what's the expected behavior when closing `sock` on exception? catch 
and throw out of the function?



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