kezhuw commented on code in PR #1782:
URL: https://github.com/apache/zookeeper/pull/1782#discussion_r2022031557
##########
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:
> try block for creating and closing is better.
We need the created socket on return, so "try-with-resources" statement is
not going to work here.
> what's the expected behavior when closing sock on exception? catch and
throw out of the function?
I think it should be catch-and-swallow. `Socket::connect` failure is the
reason to retry.
--
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]