diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/HeterogeneousRegionCountCostFunction.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/HeterogeneousRegionCountCostFunction.java index a9bb6851ad2..4b58b5d0d12 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/HeterogeneousRegionCountCostFunction.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/HeterogeneousRegionCountCostFunction.java @@ -221,11 +221,14 @@ public class HeterogeneousRegionCountCostFunction extends StochasticLoadBalancer private List readLines(BufferedReader reader) throws IOException { final List records = new ArrayList<>(); - String line; - while ((line = reader.readLine()) != null) { - records.add(line); + try { + String line; + while ((line = reader.readLine()) != null) { + records.add(line); + } + } finally { + reader.close(); } - reader.close(); return records; }