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

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

May or may not be acceptable for all users but the workaround is basically the 
same as the library fix I believe 
[https://github.com/gocd/gocd/pull/11572/commits/6969c176811056383a0d4c642d6920437d738669]

 

> 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.13.0
>
>
> 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)

Reply via email to