You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Chris Nauroth (JIRA)" <ji...@apache.org> on 2016/08/19 23:20:21 UTC

[jira] [Commented] (HADOOP-9819) FileSystem#rename is broken, deletes target when renaming link to itself

    [ https://issues.apache.org/jira/browse/HADOOP-9819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15429029#comment-15429029 ] 

Chris Nauroth commented on HADOOP-9819:
---------------------------------------

[~boky01], thank you for your patience waiting for a review on this patch.

bq. From now on we do not delete the file but throw a FileAlreadyExistsException (as other filesystems).

Can you please describe how you came to this conclusion?  Did you see this behavior from a certain {{FileSystem}} implementation?  According to the spec, we expect a "self-rename" of a file to do nothing and return {{true}}:

{code}
##### Renaming a file to self

Renaming a file to itself is a no-op; the result is `True`.

     if isFile(FS, src) and src == dest :
         FS' = FS
         result = True
{code}

This might not be consistent in implementations though.  From my quick testing, I saw HDFS and S3A following that behavior, but WASB returns {{false}}.  I haven't found a case of throwing {{FileAlreadyExistsException}}.


> 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: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org