HBASE-24174 Fix findbugs warning on ServiceAuthorizationManager (#1494)

Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
Reid Chan 2020-04-17 13:55:47 +08:00 committed by GitHub
parent d4b64c2545
commit 1eeff370c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 13 deletions

View File

@ -2202,7 +2202,6 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver {
final InetSocketAddress bindAddress, Configuration conf, final InetSocketAddress bindAddress, Configuration conf,
RpcScheduler scheduler) RpcScheduler scheduler)
throws IOException { throws IOException {
if (conf.getBoolean("hbase.ipc.server.reservoir.enabled", true)) { if (conf.getBoolean("hbase.ipc.server.reservoir.enabled", true)) {
this.reservoir = new BoundedByteBufferPool( this.reservoir = new BoundedByteBufferPool(
conf.getInt("hbase.ipc.server.reservoir.max.buffer.size", 1024 * 1024), 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) { if (scheduler instanceof ConfigurationObserver) {
((ConfigurationObserver)scheduler).onConfigurationChange(newConf); ((ConfigurationObserver)scheduler).onConfigurationChange(newConf);
} }
// Make sure authManager will read hbase-policy file if (authorize) {
System.setProperty("hadoop.policy.file", "hbase-policy.xml"); refreshAuthManager(newConf, new HBasePolicyProvider());
synchronized (authManager) {
authManager.refresh(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) { private void initReconfigurable(Configuration confToLoad) {
@ -2353,10 +2347,14 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver {
} }
@Override @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; // 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. // 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() { private AuthenticationTokenSecretManager createSecretManager() {

View File

@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.ipc;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.CellScanner; import org.apache.hadoop.hbase.CellScanner;
@ -78,10 +79,11 @@ public interface RpcServerInterface {
/** /**
* Refresh authentication manager policy. * Refresh authentication manager policy.
* @param conf configuration for refresh
* @param pp * @param pp
*/ */
@VisibleForTesting @VisibleForTesting
void refreshAuthManager(PolicyProvider pp); void refreshAuthManager(Configuration conf, PolicyProvider pp);
RpcScheduler getScheduler(); RpcScheduler getScheduler();

View File

@ -368,7 +368,7 @@ public class TestTokenAuthentication {
while (!server.isStarted() && !server.isStopped()) { while (!server.isStarted() && !server.isStopped()) {
Thread.sleep(10); Thread.sleep(10);
} }
server.rpcServer.refreshAuthManager(new PolicyProvider() { server.rpcServer.refreshAuthManager(conf, new PolicyProvider() {
@Override @Override
public Service[] getServices() { public Service[] getServices() {
return new Service [] { return new Service [] {