You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Chad Wilson (Jira)" <ji...@apache.org> on 2023/05/18 01:20:00 UTC

[jira] [Commented] (IO-791) Regression in FileUtils.touch - no longer creates parent directories

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

Chad Wilson commented on IO-791:
--------------------------------

Thanks [~ggregory] !

> Regression in FileUtils.touch - no longer creates parent directories
> --------------------------------------------------------------------
>
>                 Key: IO-791
>                 URL: https://issues.apache.org/jira/browse/IO-791
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 2.12.0
>            Reporter: Chad Wilson
>            Assignee: Gary D. Gregory
>            Priority: Major
>             Fix For: 2.12.1
>
>
> The behavior of this (and possibly other logic) seems to have regressed in 2.12.0 compared to 2.11.0. As documented in the Javadoc "Also, as from v1.3 this method creates parent directories if they do not exist." (see [here|https://github.com/apache/commons-io/blob/6921f87e35cfbd5d725011883b9d1c492f26b31d/src/main/java/org/apache/commons/io/FileUtils.java#L3077-L3091]) but this no longer works, instead it uses *PathUtils.touch* which does not have the capability of creating the parent dirs.
> {{e.g}}
> {code:java}
>     @Test
>     public void doTouch() throws Exception {
>         FileUtils.touch(new File("doesnt-exist", "touchme.txt"));
>     }{code}
> {{doesnt-exist/touchme.txt}}
> {{java.nio.file.NoSuchFileException: doesnt-exist/touchme.txt}}
> {{    at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)}}
> {{    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)}}
> {{    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)}}
> {{    at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:218)}}
> {{    at java.base/java.nio.file.Files.newByteChannel(Files.java:380)}}
> {{    at java.base/java.nio.file.Files.createFile(Files.java:658)}}
> {{    at org.apache.commons.io.file.PathUtils.touch(PathUtils.java:1613)}}
> {{    at org.apache.commons.io.FileUtils.touch(FileUtils.java:3090)}}
>  
>  
> Appears to have regressed in [https://github.com/apache/commons-io/commit/fd7c8182d2117d01f43ccc9fe939105f834ba672] - *PathUtils* relies on java.nio.Files.createFile which explicitly does not have ability to create parent directories.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)