HBASE-18894: null pointer exception in list_regions in shell command Signed-off-by: Mike Drob <md...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/176d8bd2 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/176d8bd2 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/176d8bd2 Branch: refs/heads/branch-2 Commit: 176d8bd2c7dcfc7ecb619bd48eb0c4faf94a688c Parents: 24e40f3 Author: Yi Liang <yli...@us.ibm.com> Authored: Thu Sep 28 13:07:27 2017 -0700 Committer: Mike Drob <md...@apache.org> Committed: Mon Oct 2 16:51:34 2017 -0500 ---------------------------------------------------------------------- hbase-shell/src/main/ruby/shell/commands/list_regions.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/176d8bd2/hbase-shell/src/main/ruby/shell/commands/list_regions.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/list_regions.rb b/hbase-shell/src/main/ruby/shell/commands/list_regions.rb index 5feb926..bcc0c4a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_regions.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_regions.rb @@ -77,6 +77,7 @@ EOF raise "#{cols} must be an array of strings. Possible values are SERVER_NAME, REGION_NAME, START_KEY, END_KEY, SIZE, REQ, LOCALITY." end + error = false admin_instance = admin.instance_variable_get('@admin') conn_instance = admin_instance.getConnection cluster_status = admin_instance.getClusterStatus @@ -105,6 +106,12 @@ EOF region_load_map = cluster_status.getLoad(server_name).getRegionsLoad region_load = region_load_map.get(hregion_info.getRegionName) + if region_load.nil? + puts "Can not find region: #{hregion_info.getRegionName} , it may be disabled or in transition\n" + error = true + break + end + # Ignore regions which exceed our locality threshold next unless accept_region_for_locality? region_load.getDataLocality, locality_threshold result_hash = {} @@ -157,12 +164,14 @@ EOF @end_time = Time.now + return if error + size_hash.each do |param, length| printf(" %#{length}s |", param) end printf("\n") - size_hash.each do |_param, length| + size_hash.each_value do |length| str = '-' * length printf(" %#{length}s |", str) end