Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-512

ThresholdingOutputStream.thresholdReached() results in FileNotFoundException

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 2.6
    • Component/s: Streams/Writers
    • Labels:
      None
    • Environment:

      java8 debian

      Description

      I upgraded from commons-io-2.0.1.jar to v2.5 (and fileupload to v1.32)

      and now I get

      java.io.FileNotFoundException: /usr/share/tomcat/temp/dfifp/upload_4d9f8898_1a83_4092_9070_ddf9c15de6d1_00000027.tmp (No such file or directory)
      at java.io.FileOutputStream.open(Native Method)
      at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
      at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
      at org.apache.commons.io.output.DeferredFileOutputStream.thresholdReached(DeferredFileOutputStream.java:179)

      In thresholdReached(), the prefix is null, so no temp file is created.
      In the subsequent new FileOutputStream(outputFile), the exception is thrown.

      Suggested fix:
      before new FileOutputStream(outputFile) , add

      FileUtils.forceMkdirParent(outputFile);

      Similar issues reported by others:

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              hauser@acm.org Ralf Hauser
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: