From 011989665e9ec6061d91ac5c935a52d7edf85e13 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Fri, 25 May 2018 10:25:29 -0700 Subject: [PATCH] HBASE-20597 Serialize access to a shared reference to ZooKeeperWatcher in HBaseReplicationEndpoint --- .../hbase/replication/HBaseReplicationEndpoint.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java index 6485e4afb50..6d3e70e3351 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java @@ -43,19 +43,17 @@ import org.apache.zookeeper.KeeperException.SessionExpiredException; * target cluster is an HBase cluster. */ @InterfaceAudience.Private -@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="MT_CORRECTNESS", - justification="Thinks zkw needs to be synchronized access but should be fine as is.") public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint implements Abortable { private static final Log LOG = LogFactory.getLog(HBaseReplicationEndpoint.class); - private ZooKeeperWatcher zkw = null; // FindBugs: MT_CORRECTNESS + private ZooKeeperWatcher zkw = null; private List regionServers = new ArrayList(0); private long lastRegionServerUpdate; - protected void disconnect() { + protected synchronized void disconnect() { if (zkw != null) { zkw.close(); } @@ -113,7 +111,7 @@ public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint * Get the ZK connection to this peer * @return zk connection */ - protected ZooKeeperWatcher getZkw() { + protected synchronized ZooKeeperWatcher getZkw() { return zkw; } @@ -121,7 +119,7 @@ public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint * Closes the current ZKW (if not null) and creates a new one * @throws IOException If anything goes wrong connecting */ - void reloadZkWatcher() throws IOException { + synchronized void reloadZkWatcher() throws IOException { if (zkw != null) zkw.close(); zkw = new ZooKeeperWatcher(ctx.getConfiguration(), "connection to cluster: " + ctx.getPeerId(), this);