cnauroth commented on PR #1774: URL: https://github.com/apache/zookeeper/pull/1774#issuecomment-1295509378
Assuming the cause is as described in https://github.com/apache/zookeeper/pull/1774#issuecomment-993437244 , then I'm not sure this patch would completely prevent NPEs. With this patch, we could have 2 independent threads concurrently calling `Learner#closeSockSync()`: ``` void closeSockSync() { try { long startTime = Time.currentElapsedTime(); if (sock != null) { sock.close(); sock = null; } ServerMetrics.getMetrics().SOCKET_CLOSING_TIME.add(Time.currentElapsedTime() - startTime); } catch (IOException e) { LOG.warn("Ignoring error closing connection to leader", e); } } ``` I don't believe there is any locking in effect around this operation, so it would be possible that both thread 1 and thread 2 make it past the `if (sock != null)` check, thread 1 closes and nulls the variable, and then thread 2 gets the NPE when it attempts `sock.close()`. -- 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: notifications-unsubscr...@zookeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org