li4wang commented on code in PR #1961:
URL: https://github.com/apache/zookeeper/pull/1961#discussion_r1072964684


##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java:
##########
@@ -1151,6 +1213,9 @@ protected void setLocalSessionFlag(Request si) {
     }
 
     public void submitRequest(Request si) {
+        if (state == State.MAINTENANCE) {
+            throw new IllegalStateException("Zookeeper server is in 
maintenance state");
+        }

Review Comment:
   How about using `volatile` instead of `AtomicReference` to keep it simple 
and lightweight? In this case, we only need to take care of visibility issue. 
Only one thread writes the value, so no need for the additional power (i.e. 
atomicity/CAS) provided by AtomicReference.
   
   With `volatile`,  we can ensure  once the restore thread creates a new 
instance, the instance value will be immediately visible to threads that check 
if it's null.
   



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

Reply via email to