[
https://issues.apache.org/jira/browse/IO-796?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gary D. Gregory resolved IO-796.
--------------------------------
Fix Version/s: 2.13.0
Resolution: Fixed
[~jhack]
Fixed; please test git master or a snapshot build.
> FileAlreadyExistsException in PathUtils.createParentDirectories(Path,
> LinkOption, FileAttribute<?>...)
> ------------------------------------------------------------------------------------------------------
>
> Key: IO-796
> URL: https://issues.apache.org/jira/browse/IO-796
> Project: Commons IO
> Issue Type: Bug
> Affects Versions: 2.12.0
> Reporter: Giacomo Boccardo
> Assignee: Gary D. Gregory
> Priority: Major
> Fix For: 2.13.0
>
> Attachments: FileAlreadyExistsTest.java
>
>
> Switching from 2.11.0 to 2.12.0 causes the following exception in
> commons-fileupload (1.5):
>
> {code:java}
> Caused by: java.nio.file.FileAlreadyExistsException: /home/A/B/C
> at
> java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:94)
> at
> java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
> at
> java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
> at
> java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:389)
> at java.base/java.nio.file.Files.createDirectory(Files.java:690)
> at
> java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:797)
> at java.base/java.nio.file.Files.createDirectories(Files.java:743)
> at
> org.apache.commons.io.file.PathUtils.createParentDirectories(PathUtils.java:383)
> at
> org.apache.commons.io.file.PathUtils.createParentDirectories(PathUtils.java:367)
> at
> org.apache.commons.io.output.DeferredFileOutputStream.thresholdReached(DeferredFileOutputStream.java:333)
> at
> org.apache.commons.io.output.ThresholdingOutputStream.checkThreshold(ThresholdingOutputStream.java:105)
> at
> org.apache.commons.io.output.ThresholdingOutputStream.write(ThresholdingOutputStream.java:231)
> at org.apache.commons.fileupload.util.Streams.copy(Streams.java:105)
> at
> org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:376)
> {code}
>
> where B and C are symbolic links.
>
> In particular, DeferredFileOutputStream#thresholdReached has been modified
> from:
>
>
> {code:java}
> protected void thresholdReached() throws IOException {
> if (prefix != null) {
> outputFile = File.createTempFile(prefix, suffix, directory);
> }
> FileUtils.forceMkdirParent(outputFile);
> final OutputStream fos = Files.newOutputStream(outputFile.toPath());
> [...]
> }
> {code}
>
> to:
>
> {code:java}
> protected void thresholdReached() throws IOException {
> if (prefix != null) {
> outputPath = Files.createTempFile(directory, prefix, suffix);
> }
> PathUtils.createParentDirectories(outputPath);
> final OutputStream fos = Files.newOutputStream(outputPath);
>
> [...]
> } {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)