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

ThresholdingOutputStream.thresholdReached() results in FileNotFoundException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5
    • 2.6
    • Streams/Writers
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: