diff --git a/dev-support/spotbugs-exclude.xml b/dev-support/spotbugs-exclude.xml index 1137f5fdc14..2f0684eff4d 100644 --- a/dev-support/spotbugs-exclude.xml +++ b/dev-support/spotbugs-exclude.xml @@ -252,4 +252,23 @@ + + + + + + + + + + + + + + + diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java index f34cad5f60c..de958b8ce7d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java @@ -136,8 +136,12 @@ public class NettyRpcServer extends RpcServer { } authTokenSecretMgr = createSecretManager(); if (authTokenSecretMgr != null) { - setSecretManager(authTokenSecretMgr); - authTokenSecretMgr.start(); + // Start AuthenticationTokenSecretManager in synchronized way to avoid race conditions in + // LeaderElector start. See HBASE-25875 + synchronized (authTokenSecretMgr) { + setSecretManager(authTokenSecretMgr); + authTokenSecretMgr.start(); + } } this.authManager = new ServiceAuthorizationManager(); HBasePolicyProvider.init(conf, authManager); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java index cbcbc9a8f7a..7818572dd3d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java @@ -423,8 +423,12 @@ public class SimpleRpcServer extends RpcServer { } authTokenSecretMgr = createSecretManager(); if (authTokenSecretMgr != null) { - setSecretManager(authTokenSecretMgr); - authTokenSecretMgr.start(); + // Start AuthenticationTokenSecretManager in synchronized way to avoid race conditions in + // LeaderElector start. See HBASE-25875 + synchronized (authTokenSecretMgr) { + setSecretManager(authTokenSecretMgr); + authTokenSecretMgr.start(); + } } this.authManager = new ServiceAuthorizationManager(); HBasePolicyProvider.init(conf, authManager);