[
https://issues.apache.org/jira/browse/IO-695?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17262436#comment-17262436
]
Gary D. Gregory commented on IO-695:
------------------------------------
Hi [~morvael],
The copy API makes sure that the operation you asked it to perform
(preserveFileDate=true) actually worked. Since failing silently is what the JRE
does (no exception is thrown, instead the method returns a boolean), we
validate this operation manually by throwing an IOException. As I am sure you
know, most JRE IO APIs throw IOException, but for some of these very old APIs,
they return a boolean instead.
If you do not care about a failure when setting the file's timestamp, then do
not ask for that operation to be performed in the first place by setting
preserveFileDate to false.
Now that the docs are fixed, we can close this ticket IMO.
> Exception while there should be none in copyFile
> ------------------------------------------------
>
> Key: IO-695
> URL: https://issues.apache.org/jira/browse/IO-695
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.8.0
> Reporter: Dominik DerwiĆski
> Priority: Minor
>
> {{public static void copyFile(final File srcFile, final File destFile, final
> boolean preserveFileDate)}} java doc says: "If the modification operation
> fails, no indication is provided", yet the method raises an {{IOException}}
> "Failed setLastModified on ...".
--
This message was sent by Atlassian Jira
(v8.3.4#803005)