[
https://issues.apache.org/jira/browse/YARN-9531?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
eBugs updated YARN-9531:
------------------------
Description:
Dear YARN 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-yarn-project/hadoop-yarn/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/AllocationFileLoaderService.java
Line: 199-200
{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 {{getAllocationFile()}} can't find the allocation file
on the local filesystem. This mismatch could be a problem. For example, the
callers may miss the case where {{getAllocationFile()}} fails to find the file
since it does not throw any {{FileNotFoundException}}. Or, the callers trying
to handle other {{RuntimeException}} may accidentally (and incorrectly) handle
the file not found scenario. Throwing a more specific class, or wrapping a
{{FileNotFoundException}} may be better here.
was:
Dear YARN 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: Hadoop-3.1.2
File:
HADOOP-ROOT/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/AllocationFileLoaderService.java
Line: 199-200
{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 {{getAllocationFile()}} can't find the allocation file
on the local filesystem. This mismatch could be a problem. For example, the
callers may miss the case where {{getAllocationFile()}} fails to find the file
since it does not throw any {{FileNotFoundException}}. Or, the callers trying
to handle other {{RuntimeException}} may accidentally (and incorrectly) handle
the file not found scenario. Throwing a more specific class, or wrapping a
{{FileNotFoundException}} may be better here.
> AllocationFileLoaderService.getAllocationFile() throws a RuntimeException if
> it can't find the file on the local filesystem
> ---------------------------------------------------------------------------------------------------------------------------
>
> Key: YARN-9531
> URL: https://issues.apache.org/jira/browse/YARN-9531
> Project: Hadoop YARN
> Issue Type: Bug
> Reporter: eBugs
> Priority: Minor
>
> Dear YARN 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-yarn-project/hadoop-yarn/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/AllocationFileLoaderService.java
> Line: 199-200
> {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 {{getAllocationFile()}} can't find the allocation file
> on the local filesystem. This mismatch could be a problem. For example, the
> callers may miss the case where {{getAllocationFile()}} fails to find the
> file since it does not throw any {{FileNotFoundException}}. Or, the callers
> trying to handle other {{RuntimeException}} may accidentally (and
> incorrectly) handle the file not found scenario. Throwing a more specific
> class, or wrapping a {{FileNotFoundException}} may 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]