Details
-
Sub-task
-
Status: Resolved
-
Minor
-
Resolution: Not A Problem
-
None
-
None
-
None
-
None
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
try { daemon.join(); } catch (InterruptedException e) { throw new RuntimeException("failed to join thread"); }
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 the interrupt. If throwing checked exceptions is not preferred, wrapping the InterruptedException can be better here.