[
https://issues.apache.org/jira/browse/HDFS-14474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
eBugs updated HDFS-14474:
-------------------------
Description:
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}
try {
daemon.join();
} catch (InterruptedException e) {
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}} can be better here.
was:
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}
try {
daemon.join();
} catch (InterruptedException e) {
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.
> 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
> Priority: Minor
>
> 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}
> try {
> daemon.join();
> } catch (InterruptedException e) {
> 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}} can be better here.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]