[ 
https://issues.apache.org/jira/browse/HBASE-22089?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16799584#comment-16799584
 ] 

kevin su edited comment on HBASE-22089 at 3/28/19 12:42 AM:
------------------------------------------------------------

[~water] I found that there is a function *_isInitialized_* in Hmaster, It will 
set to true after initClusterSchemaService was completed.

So,I will use *_this.master.isInitialized()_* to check if this is completed, if 
no,It will give a log 

{code}LOG.debug("Master has not been initialized, don't 
assignTableToGroup.");{code}

And then return NULL.

What do you think? 



was (Author: pingsutw):
[~water] I found that there is a function *_isInitialized_* in Hmaster, It will 
set to true after initClusterSchemaService was completed.

So,I will use *_this.master.isInitialized()_* to check if this is completed, if 
no,It will give a log 

{code}LOG.debug("Master has not been initialized, don't get 
NamespaceDescriptor.");{code}

And then return NULL.

What do you think? 


> HMaster#getClusterSchema() could return null and cause NPE
> ----------------------------------------------------------
>
>                 Key: HBASE-22089
>                 URL: https://issues.apache.org/jira/browse/HBASE-22089
>             Project: HBase
>          Issue Type: Improvement
>          Components: master
>            Reporter: Xiang Li
>            Assignee: kevin su
>            Priority: Minor
>
> HMaster#getClusterSchema() has a lot of usage, for example:
> {code:title=hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java|borderStyle=solid}
> void assignTableToGroup(TableDescriptor desc) throws IOException {
>   String groupName =
>       
> master.getClusterSchema().getNamespace(desc.getTableName().getNamespaceAsString())
>                 .getConfigurationValue(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP);
>   ...
> }
> {code}
> getClusterSchema() might return null when cluster schema service is not ready 
> yet. Actually, it won't be ready until HMaster#initClusterSchemaService() is 
> finished. See [this 
> comment|https://issues.apache.org/jira/browse/HBASE-20690?focusedCommentId=16784549&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16784549]
>  for details.
> We need to add protections, like adding null check before calling 
> getClusterSchema().getXXX(), or in HMaster#getClusterSchema(), add a loop to 
> wait until this.clusterSchemaService is not null.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to