From 6cf4fdde61dcd59cf585b3368a71dc6af17c4498 Mon Sep 17 00:00:00 2001 From: xiaoyu <549477611@qq.com> Date: Fri, 16 Apr 2021 02:04:06 +0800 Subject: [PATCH] HBASE-25776 Use Class.asSubclass to fix the warning in StochasticLoadBalancer.loadCustomCostFunctions (#3163) Signed-off-by: Duo Zhang Signed-off-by: Viraj Jasani --- .../hadoop/hbase/master/balancer/StochasticLoadBalancer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java index 000a185dab7..b40779ade23 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java @@ -249,7 +249,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer { costFunctions.addAll(Arrays.stream(functionsNames).map(c -> { Class klass = null; try { - klass = (Class) Class.forName(c); + klass = Class.forName(c).asSubclass(CostFunction.class); } catch (ClassNotFoundException e) { LOG.warn("Cannot load class " + c + "': " + e.getMessage()); }