You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by re...@apache.org on 2020/04/17 05:56:00 UTC

[hbase] branch branch-1 updated: HBASE-24174 Fix findbugs warning on ServiceAuthorizationManager (#1494)

This is an automated email from the ASF dual-hosted git repository.

reidchan pushed a commit to branch branch-1
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-1 by this push:
     new 1eeff37  HBASE-24174 Fix findbugs warning on ServiceAuthorizationManager (#1494)
1eeff37 is described below

commit 1eeff370c46d0db1e4852173187f315d1292fbb8
Author: Reid Chan <re...@apache.org>
AuthorDate: Fri Apr 17 13:55:47 2020 +0800

    HBASE-24174 Fix findbugs warning on ServiceAuthorizationManager (#1494)
    
    Signed-off-by: Viraj Jasani <vj...@apache.org>
---
 .../java/org/apache/hadoop/hbase/ipc/RpcServer.java    | 18 ++++++++----------
 .../apache/hadoop/hbase/ipc/RpcServerInterface.java    |  6 ++++--
 .../hbase/security/token/TestTokenAuthentication.java  |  2 +-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
index 5daa42b..f62a218 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
@@ -2202,7 +2202,6 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver {
       final InetSocketAddress bindAddress, Configuration conf,
       RpcScheduler scheduler)
       throws IOException {
-    
     if (conf.getBoolean("hbase.ipc.server.reservoir.enabled", true)) {
       this.reservoir = new BoundedByteBufferPool(
           conf.getInt("hbase.ipc.server.reservoir.max.buffer.size", 1024 * 1024),
@@ -2265,14 +2264,9 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver {
     if (scheduler instanceof ConfigurationObserver) {
       ((ConfigurationObserver)scheduler).onConfigurationChange(newConf);
     }
-    // Make sure authManager will read hbase-policy file
-    System.setProperty("hadoop.policy.file", "hbase-policy.xml");
-    synchronized (authManager) {
-      authManager.refresh(newConf, new HBasePolicyProvider());
+    if (authorize) {
+      refreshAuthManager(newConf, new HBasePolicyProvider());
     }
-    LOG.info("Refreshed hbase-policy.xml successfully");
-    ProxyUsers.refreshSuperUserGroupsConfiguration(newConf);
-    LOG.info("Refreshed super and proxy users successfully");
   }
 
   private void initReconfigurable(Configuration confToLoad) {
@@ -2353,10 +2347,14 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver {
   }
 
   @Override
-  public synchronized void refreshAuthManager(PolicyProvider pp) {
+  public synchronized void refreshAuthManager(Configuration conf, PolicyProvider pp) {
     // Ignore warnings that this should be accessed in a static way instead of via an instance;
     // it'll break if you go via static route.
-    this.authManager.refresh(this.conf, pp);
+    System.setProperty("hadoop.policy.file", "hbase-policy.xml");
+    this.authManager.refresh(conf, pp);
+    LOG.info("Refreshed hbase-policy.xml successfully");
+    ProxyUsers.refreshSuperUserGroupsConfiguration(conf);
+    LOG.info("Refreshed super and proxy users successfully");
   }
 
   private AuthenticationTokenSecretManager createSecretManager() {
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerInterface.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerInterface.java
index bae5a0a..a6cb9eb 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerInterface.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerInterface.java
@@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.ipc;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.classification.InterfaceStability;
 import org.apache.hadoop.hbase.CellScanner;
@@ -78,11 +79,12 @@ public interface RpcServerInterface {
 
   /**
    * Refresh authentication manager policy.
+   * @param conf configuration for refresh
    * @param pp
    */
   @VisibleForTesting
-  void refreshAuthManager(PolicyProvider pp);
-  
+  void refreshAuthManager(Configuration conf, PolicyProvider pp);
+
   RpcScheduler getScheduler();
 
   void setRsRpcServices(RSRpcServices rsRpcServices);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
index 6a659cb..4eac350 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
@@ -368,7 +368,7 @@ public class TestTokenAuthentication {
     while (!server.isStarted() && !server.isStopped()) {
       Thread.sleep(10);
     }
-    server.rpcServer.refreshAuthManager(new PolicyProvider() {
+    server.rpcServer.refreshAuthManager(conf, new PolicyProvider() {
       @Override
       public Service[] getServices() {
         return new Service [] {