From af25940b2588648bdac8331c312e1be0ac396b67 Mon Sep 17 00:00:00 2001 From: QilinCao Date: Wed, 21 Jun 2017 18:34:29 +0800 Subject: [PATCH] HBASE-18252 Resolve BaseLoadBalancer bad practice warnings Signed-off-by: tedyu --- .../hbase/master/balancer/BaseLoadBalancer.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java index 3556e1774a6..fda9f60ef91 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java @@ -914,7 +914,7 @@ public abstract class BaseLoadBalancer implements LoadBalancer { private Comparator numRegionsComparator = new Comparator() { @Override public int compare(Integer integer, Integer integer2) { - return Integer.valueOf(getNumRegions(integer)).compareTo(getNumRegions(integer2)); + return Integer.compare(getNumRegions(integer), getNumRegions(integer2)); } }; @@ -929,15 +929,7 @@ public abstract class BaseLoadBalancer implements LoadBalancer { private Comparator localityComparator = new Comparator() { @Override public int compare(Integer integer, Integer integer2) { - float locality1 = getLocality(integer); - float locality2 = getLocality(integer2); - if (locality1 < locality2) { - return -1; - } else if (locality1 > locality2) { - return 1; - } else { - return 0; - } + return Float.compare(getLocality(integer), getLocality(integer2)); } };