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)); } };