Description
Uncovered while fixing TestSymlinkLocalFsFileSystem on Windows.
This block of code deletes the symlink, the correct behavior is to do nothing.
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);