anmolnar commented on code in PR #2154:
URL: https://github.com/apache/zookeeper/pull/2154#discussion_r1765409046
##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Learner.java:
##########
@@ -900,26 +900,26 @@ boolean isRunning() {
}
void closeSocket() {
- if (sock != null) {
- if (sockBeingClosed.compareAndSet(false, true)) {
- if (closeSocketAsync) {
- final Thread closingThread = new Thread(() ->
closeSockSync(), "CloseSocketThread(sid:" + zk.getServerId());
- closingThread.setDaemon(true);
- closingThread.start();
- } else {
- closeSockSync();
- }
+ if (sockBeingClosed.compareAndSet(false, true)) {
+ if (sock == null) { // Closing before establishing the connection
is a noop
+ return;
+ }
Review Comment:
nit: Why have you moved the null check inside the lock?
--
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]