Commons FileUpload
  1. Commons FileUpload
  2. FILEUPLOAD-193

FileNotFoundException thrown by DiskFileItem.write

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.2.2
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Ubuntu 10.10

      java version "1.6.0_24"
      Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
      Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)

      Description

      Under certain conditions the DiskFileItem.write throws a FileNotFound exception. It seems to be when outputFile.renameTo(file) fails.

      java.io.FileNotFoundException: /tmp/UploadController/uploading/upload_69651d04_13000a31964__8000_00001651.tmp (No such file or directory)
              at java.io.FileInputStream.open(Native Method)
              at java.io.FileInputStream.<init>(FileInputStream.java:106)
              at org.apache.commons.fileupload.disk.DiskFileItem.write(DiskFileItem.java:447)
              at upload.UploadController.handle(UploadController.java:90)
              ...

      I can't see any obvious reason why the source file (outputFile) wouldn't exist...

        Activity

        Dan Washusen created issue -
        Dan Washusen made changes -
        Field Original Value New Value
        Description Under certain conditions the DiskFileItem.write throws a FileNotFound exception. It seems to be when outputFile.renameTo(file) fails...

        A little digging seems to suggest that the following code is back to front:
        {code}in = new BufferedInputStream(
            new FileInputStream(outputFile));
        out = new BufferedOutputStream(
                new FileOutputStream(file));
        IOUtils.copy(in, out);{code}

        It seems to be trying to copy the outputFile (which doesn't exist yet) to the input file.

        {code}java.io.FileNotFoundException: /tmp/UploadController/uploading/upload_69651d04_13000a31964__8000_00001651.tmp (No such file or directory)
                at java.io.FileInputStream.open(Native Method)
                at java.io.FileInputStream.<init>(FileInputStream.java:106)
                at org.apache.commons.fileupload.disk.DiskFileItem.write(DiskFileItem.java:447)
                at upload.UploadController.handle(UploadController.java:90){code}
        Under certain conditions the DiskFileItem.write throws a FileNotFound exception. It seems to be when outputFile.renameTo(file) fails.

        {code}java.io.FileNotFoundException: /tmp/UploadController/uploading/upload_69651d04_13000a31964__8000_00001651.tmp (No such file or directory)
                at java.io.FileInputStream.open(Native Method)
                at java.io.FileInputStream.<init>(FileInputStream.java:106)
                at org.apache.commons.fileupload.disk.DiskFileItem.write(DiskFileItem.java:447)
                at upload.UploadController.handle(UploadController.java:90)
                ...{code}

        I can't see any obvious reason why the source file (outputFile) wouldn't exist...
        Simone Tripodi made changes -
        Affects Version/s 2.0.0 [ 12312801 ]
        Affects Version/s 1.2.2 [ 12315238 ]
        Fix Version/s 1.2.2 [ 12315238 ]
        Simone Tripodi made changes -
        Affects Version/s 1.2.2 [ 12315238 ]
        Affects Version/s 2.0.0 [ 12312801 ]
        Fix Version/s 2.0.0 [ 12312801 ]
        Fix Version/s 1.2.2 [ 12315238 ]
        Simone Tripodi made changes -
        Fix Version/s 1.3 [ 12312801 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Dan Washusen
          • Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:

              Development