imbajin commented on code in PR #2151:
URL: 
https://github.com/apache/incubator-hugegraph/pull/2151#discussion_r1130660219


##########
hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/GlobalMasterInfo.java:
##########
@@ -19,26 +19,20 @@
 
 public class GlobalMasterInfo {
 
-    private boolean isMaster;
-    private String url;
-
+    private volatile Info info;
     private volatile boolean featureSupport;
 
     public GlobalMasterInfo() {
         this.featureSupport = false;
+        this.info = new Info(false, "");
     }
 
-    public synchronized void set(boolean isMaster, String url) {
-        this.isMaster = isMaster;
-        this.url = url;
-    }
-
-    public synchronized boolean isMaster() {
-        return this.isMaster;
+    public void info(boolean isMaster, String url) {
+        this.info = new Info(isMaster, url);

Review Comment:
   > info define with volatile, so as my think, the write operator 
happens-before read operator, so if write operator happend first, the read 
operator must after the write finish
   
   ```java
           public Info(boolean isMaster, String url) {
               this.isMaster = isMaster; // ①
               this.url = url; // ②
           }
   ```
   
   `new Info` include ① & ② step, when ① is finished but ② is not, will we see 
an inconsistent assignments?
   
   like `Info info = new Info(true, "a")`, will we get `Info(true, "")` or 
`Info(false, "a")`?
   



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

Reply via email to