Michael Blow has submitted this change and it was merged.

Change subject: SONAR: Synchronization On Boxed Primitives
......................................................................


SONAR: Synchronization On Boxed Primitives

Synchronization should not be based on Strings or boxed primitives

Fixes:
 - https://asterix-sonar.ics.uci.edu/issues/search#issues=AVR98lUKuXNBBqjTzg_N
 - https://asterix-sonar.ics.uci.edu/issues/search#issues=AVR98lUKuXNBBqjTzg_O
 - https://asterix-sonar.ics.uci.edu/issues/search#issues=AVR98lUKuXNBBqjTzg_P

Change-Id: I520582cb5a03d775d696ec5b4390b571322e18f7
Reviewed-on: https://asterix-gerrit.ics.uci.edu/853
Tested-by: Jenkins <[email protected]>
Reviewed-by: abdullah alamoudi <[email protected]>
---
M 
asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ClusterStateWatcher.java
1 file changed, 3 insertions(+), 6 deletions(-)

Approvals:
  abdullah alamoudi: Looks good to me, approved
  Jenkins: Verified



diff --git 
a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ClusterStateWatcher.java
 
b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ClusterStateWatcher.java
index 2ef8697..f823404 100644
--- 
a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ClusterStateWatcher.java
+++ 
b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ClusterStateWatcher.java
@@ -25,8 +25,8 @@
 
 //A zookeeper watcher that watches the change in the state of the cluster
 public class ClusterStateWatcher implements Watcher {
-    private static Integer mutex;
-    private static ZooKeeper zk;
+    private final Object mutex = new Object();
+    private final ZooKeeper zk;
     private String clusterStatePath;
     private boolean done = false;
     private ClusterState clusterState = ClusterState.STARTING;
@@ -35,12 +35,9 @@
     private static Logger LOGGER = 
Logger.getLogger(ClusterStateWatcher.class.getName());
 
     public ClusterStateWatcher(ZooKeeper zk, String clusterName) {
-        if (mutex == null) {
-            mutex = new Integer(-1);
-        }
         this.clusterStatePath = ZooKeeperService.ASTERIX_INSTANCE_BASE_PATH + 
File.separator + clusterName
                 + ZooKeeperService.ASTERIX_INSTANCE_STATE_PATH;
-        ClusterStateWatcher.zk = zk;
+        this.zk = zk;
     }
 
     public ClusterState waitForClusterStart() throws Exception {

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/853
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I520582cb5a03d775d696ec5b4390b571322e18f7
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <[email protected]>
Gerrit-Reviewer: Jenkins <[email protected]>
Gerrit-Reviewer: Michael Blow <[email protected]>
Gerrit-Reviewer: abdullah alamoudi <[email protected]>

Reply via email to