eBugs created HDFS-14474:
----------------------------

             Summary: PeerCache.close() throws a RuntimeException when it is 
interrupted
                 Key: HDFS-14474
                 URL: https://issues.apache.org/jira/browse/HDFS-14474
             Project: Hadoop HDFS
          Issue Type: Bug
            Reporter: eBugs


Dear HDFS 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 indicate different error conditions.

 

Version: Hadoop-3.1.2

File: 
HADOOP-ROOT/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/PeerCache.java

Line: 283
{code:java}
throw new RuntimeException("failed to join thread");{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 {{close()}} is interrupted. This mismatch could be a 
problem. For example, the callers may miss the interrupt. Or, the callers 
trying to handle other {{RuntimeException}} may accidentally (and incorrectly) 
handle interrupt. If throwing checked exceptions is not preferred, wrapping the 
{{InterruptedException}} is better here.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-dev-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-dev-h...@hadoop.apache.org

Reply via email to