[ https://issues.apache.org/jira/browse/HADOOP-16296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
eBugs updated HADOOP-16296: --------------------------- Description: Dear Hadoop 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-common-project/hadoop-minikdc/src/main/java/org/apache/hadoop/minikdc/MiniKdc.java Line: 223 {code:java} throw new RuntimeException("Cannot create directory " + this.workDir);{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 {{MiniKdc()}} can't create the directory {{workDir}}. This mismatch could be a problem. For example, the callers may miss the case where {{MiniKdc()}} fails to create the directory. Or, the callers trying to handle other {{RuntimeException}} may accidentally (and incorrectly) handle the directory creation failure. Maybe throwing an {{IOException}} is better here. was: Dear Hadoop 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-common-project/hadoop-minikdc/src/main/java/org/apache/hadoop/minikdc/MiniKdc.java Line: 223 {code:java} throw new RuntimeException("Allocation file " + url + " found on the classpath is not on the local filesystem.");{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 {{MiniKdc()}} can't create the directory {{workDir}}. This mismatch could be a problem. For example, the callers may miss the case where {{MiniKdc()}} fails to create the directory. Or, the callers trying to handle other {{RuntimeException}} may accidentally (and incorrectly) handle the directory creation failure. Maybe throwing an {{IOException}} is better here. > MiniKdc() throws a RuntimeException when it fails to create its workDir > ----------------------------------------------------------------------- > > Key: HADOOP-16296 > URL: https://issues.apache.org/jira/browse/HADOOP-16296 > Project: Hadoop Common > Issue Type: Bug > Reporter: eBugs > Priority: Minor > > Dear Hadoop 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-common-project/hadoop-minikdc/src/main/java/org/apache/hadoop/minikdc/MiniKdc.java > Line: 223 > {code:java} > throw new RuntimeException("Cannot create directory " + this.workDir);{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 {{MiniKdc()}} can't create the directory {{workDir}}. > This mismatch could be a problem. For example, the callers may miss the case > where {{MiniKdc()}} fails to create the directory. Or, the callers trying to > handle other {{RuntimeException}} may accidentally (and incorrectly) handle > the directory creation failure. Maybe throwing an {{IOException}} is better > here. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org