HBASE-25776 Use Class.asSubclass to fix the warning in StochasticLoadBalancer.loadCustomCostFunctions (#3163)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
xiaoyu 2021-04-16 02:04:06 +08:00 committed by Viraj Jasani
parent 69e93c8137
commit 22fd7d7f10
No known key found for this signature in database
GPG Key ID: 08E70F70AB71C5A1
1 changed files with 1 additions and 1 deletions

View File

@ -247,7 +247,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
costFunctions.addAll(Arrays.stream(functionsNames).map(c -> {
Class<? extends CostFunction> klass = null;
try {
klass = (Class<? extends CostFunction>) Class.forName(c);
klass = Class.forName(c).asSubclass(CostFunction.class);
} catch (ClassNotFoundException e) {
LOG.warn("Cannot load class " + c + "': " + e.getMessage());
}