From d8f8a5823666f2d0a7af895b9dfe6eddb7490138 Mon Sep 17 00:00:00 2001 From: Enis Soztutar Date: Tue, 9 Sep 2014 18:35:53 -0700 Subject: [PATCH] HBASE-11923 Potential race condition in RecoverableZookeeper.checkZk() (Lars Hofhansl) --- .../apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java index 0614bfed747..ca359719488 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java @@ -75,7 +75,7 @@ import org.htrace.TraceScope; public class RecoverableZooKeeper { private static final Log LOG = LogFactory.getLog(RecoverableZooKeeper.class); // the actual ZooKeeper client instance - volatile private ZooKeeper zk; + private ZooKeeper zk; private final RetryCounterFactory retryCounterFactory; // An identifier of this process in the cluster private final String identifier; @@ -134,7 +134,7 @@ public class RecoverableZooKeeper { * @return The created Zookeeper connection object * @throws KeeperException */ - protected ZooKeeper checkZk() throws KeeperException { + protected synchronized ZooKeeper checkZk() throws KeeperException { if (this.zk == null) { try { this.zk = new ZooKeeper(quorumServers, sessionTimeout, watcher); @@ -146,7 +146,7 @@ public class RecoverableZooKeeper { return zk; } - public void reconnectAfterExpiration() + public synchronized void reconnectAfterExpiration() throws IOException, KeeperException, InterruptedException { if (zk != null) { LOG.info("Closing dead ZooKeeper connection, session" +