[
https://issues.apache.org/jira/browse/HADOOP-16295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16834899#comment-16834899
]
eBugs commented on HADOOP-16295:
--------------------------------
After looking at the related code, I found that one of FileUtil.replaceFile()'s
callers, FileIoProvider.replaceFile(), catches all {{Exception}} and checks for
disk error:
{code:java}
public void replaceFile(...) throws IOException {
...
try {
...
FileUtil.replaceFile(src, target);
...
} catch(Exception e) {
onFailure(volume, begin); // This calls DataNode.checkDiskErrorAsync()
throw e;
}
}{code}
If the exception is thrown because of an interrupt, maybe the disk check can be
skipped? If so, throwing an {{InterruptedIOException}} makes it easier to
differentiate interrupts from actual file system errors, which also throw
{{IOExceptions}}, e.g., FileUtil.replaceFile()#line1390-1394:
{code:java}
if (!src.renameTo(target)) {
throw new IOException("Unable to rename " + src +
" to " + target);
}
{code}
> FileUtil.replaceFile() throws an IOException when it is interrupted
> -------------------------------------------------------------------
>
> Key: HADOOP-16295
> URL: https://issues.apache.org/jira/browse/HADOOP-16295
> Project: Hadoop Common
> Issue Type: Sub-task
> 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-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
> Line: 1387
> {code:java}
> throw new IOException("replaceFile interrupted.");{code}
>
> An {{IOException}} can mean many different errors, while the error message
> indicates that {{replaceFile()}} is interrupted. This mismatch could be a
> problem. For example, the callers trying to handle other {{IOException}} may
> accidentally (and incorrectly) handle the interrupt. An
> {{InterruptedIOException}} 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]