Github user nkalmar commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/724#discussion_r238194209
  
    --- Diff: 
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumPeer.java
 ---
    @@ -1162,10 +1162,12 @@ public void run() {
                             };
                             try {
                                 roZkMgr.start();
    -                            reconfigFlagClear();
    -                            if (shuttingDownLE) {
    -                                shuttingDownLE = false;
    -                                startLeaderElection();
    +                            synchronized (this) {
    +                                reconfigFlagClear();
    +                                if (shuttingDownLE) {
    --- End diff --
    
    Wouldn't it make more sense to make shuttingDownLE AtomicBoolean and use 
compareAndSet() here? The two methods (reconfigFlagClear and 
startLeaderElection) is already synchronized anyway, and only synchronized 
blocks access shuttingDownLE.
    
    What do you think?


---

Reply via email to