[
https://issues.apache.org/jira/browse/HADOOP-9819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15468266#comment-15468266
]
Chris Nauroth commented on HADOOP-9819:
---------------------------------------
[~boky01], thank you for the further details.
I think the source of my confusion was that the specification I quoted above
describes the behavior of {{FileSystem#rename}}. I now realize this patch is
focused on the code path invoked through {{FileContext#rename}}, which uses a
different error reporting model; there is no return value and all errors are
reported through exceptions. I filed HADOOP-13581 as a separate issue to
propose improving the specification's description of {{FileContext}} behavior.
The specific {{rename}} method in question here is kind of unusual. It's in
{{FileSystem}}, but it really only exists as an internal detail to help bridge
callers trying to transition to {{FileContext}}. That means that even though
the proposed patch changes {{FileSystem}}, it really only impacts behavior of
{{FileContext}} and does not violate statements made in the specification,
which is focused on {{FileSystem}}.
The patch needs a rebase, but I will likely be +1 after that. I would like a
second code review though given the general sensitivity of {{rename}}.
[[email protected]], are you interested?
> FileSystem#rename is broken, deletes target when renaming link to itself
> ------------------------------------------------------------------------
>
> Key: HADOOP-9819
> URL: https://issues.apache.org/jira/browse/HADOOP-9819
> Project: Hadoop Common
> Issue Type: Sub-task
> Components: fs
> Affects Versions: 3.0.0-alpha1
> Reporter: Arpit Agarwal
> Assignee: Andras Bokor
> Attachments: HADOOP-9819.01.patch, HADOOP-9819.02.patch,
> HADOOP-9819.03.patch
>
>
> Uncovered while fixing TestSymlinkLocalFsFileSystem on Windows.
> This block of code deletes the symlink, the correct behavior is to do nothing.
> {code:java}
> try {
> dstStatus = getFileLinkStatus(dst);
> } catch (IOException e) {
> dstStatus = null;
> }
> if (dstStatus != null) {
> if (srcStatus.isDirectory() != dstStatus.isDirectory()) {
> throw new IOException("Source " + src + " Destination " + dst
> + " both should be either file or directory");
> }
> if (!overwrite) {
> throw new FileAlreadyExistsException("rename destination " + dst
> + " already exists.");
> }
> // Delete the destination that is a file or an empty directory
> if (dstStatus.isDirectory()) {
> FileStatus[] list = listStatus(dst);
> if (list != null && list.length != 0) {
> throw new IOException(
> "rename cannot overwrite non empty destination directory " +
> dst);
> }
> }
> delete(dst, false);
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]