You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Pascal Schumacher (JIRA)" <ji...@apache.org> on 2017/04/23 18:24:04 UTC

[jira] [Closed] (IO-411) moveFile throws Exception prematurely?

     [ https://issues.apache.org/jira/browse/IO-411?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pascal Schumacher closed IO-411.
--------------------------------
    Resolution: Invalid

Hi Nick,

thanks for reporting.

The implementation is correct. FilesUtils.deleteQuietly is called with the destination file (not the source file).

> moveFile throws Exception prematurely?
> --------------------------------------
>
>                 Key: IO-411
>                 URL: https://issues.apache.org/jira/browse/IO-411
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 2.4
>            Reporter: Nick
>            Priority: Minor
>
> This may not be an issue, but I noticed that the moveFile command throws an exception after trying and ignoring the return value of deleteQuietly. Look at line 2969 below.
> Taken from SVN head:
> {code}
> 2965         final boolean rename = srcFile.renameTo(destFile);
> 2966	        if (!rename) {
> 2967	            copyFile( srcFile, destFile );
> 2968	            if (!srcFile.delete()) {
> 2969	                FileUtils.deleteQuietly(destFile);
> 2970	                throw new IOException("Failed to delete original file '" srcFile + "' after copy to '" + destFile + "'");
> 2972	            }
> 2973	        }
> {code}
> deleteQuietly will just end up trying File.delete() again which will likely fail at that point, but still, shouldn't there be another if statement there?
> Note: Haven't actually had issues with this.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)