commit | bba05b7bbad0a9d9be38fd14dcd0409505695d7b | [log] [tgz] |
---|---|---|
author | Michael Blow <mblow@apache.org> | Mon May 16 14:21:30 2016 -0700 |
committer | Michael Blow <michael.blow@couchbase.com> | Tue May 17 08:50:36 2016 -0700 |
tree | 47836fad921c029382171dbd50e70f5c7a7ce8d3 | |
parent | e5bff31d5ee5ab0930d39719869b795bf234bb3c [diff] |
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 <jenkins@fulliautomatix.ics.uci.edu> Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
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 {