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

Xu Cang commented on HBASE-22369:
---------------------------------

This is the common way HBase code deals with situations that we don't want to 
proceed.

Such as

[https://github.com/apache/hbase/blob/025ddce868eb06b4072b5152c5ffae5a01e7ae30/hbase-server/src/test/java/org/apache/hadoop/hbase/util/HBaseHomePath.java#L39]

> CoprocessorClassLoader.init() throws a RuntimeException when it fails to 
> create a directory
> -------------------------------------------------------------------------------------------
>
>                 Key: HBASE-22369
>                 URL: https://issues.apache.org/jira/browse/HBASE-22369
>             Project: HBase
>          Issue Type: Bug
>    Affects Versions: 2.1.4
>            Reporter: eBugs
>            Priority: Minor
>
> Dear HBase developers, we are developing a tool to detect exception-related 
> bugs in Java. Our prototype has spotted the following {{throw}} statement 
> whose exception class and error message seem to indicate different error 
> conditions.
>  
> Version: HBase-2.1.4 
> File: 
> HBASE-ROOT/hbase-common/src/java/org/apache/hbase/utils/CoprocessorClassLoader.java
> Line: 160-161
> {code:java}
> throw new RuntimeException("Failed to create local dir " + parentDirStr
>   + ", CoprocessorClassLoader failed to init");{code}
>  
> {{RuntimeException}} is usually used to represent errors in the program logic 
> (think of one of its subclasses, {{NullPointerException}}), while the error 
> message indicates that {{init()}} failed to create a directory. This mismatch 
> could be a problem. For example, the callers may miss the case where 
> {{init()}} fails to create a directory. Or, the callers trying to handle 
> other {{RuntimeException}} may accidentally (and incorrectly) handle the 
> directory creation failure.



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

Reply via email to