Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-5146

Empty file upload ends in error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • 2.5.26
    • 6.0.0
    • Core Interceptors

    Description

      After upgrading to 2.5.26, uploading an empty file now ends with: "Error uploading: empty_file.txt"
      This was working fine with Struts 2.5.20
      Seems the behavior change occurred somewhere in 2.5.22 - 2.5.5.25

      In org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest:

      protected DiskFileItemFactory createDiskFileItemFactory(String saveDir) {
         DiskFileItemFactory fac = new DiskFileItemFactory();
         // Make sure that the data is written to file
         fac.setSizeThreshold(0);
         if (saveDir != null) {
           fac.setRepository(new File(saveDir));
         }
         return fac;
       }
      

      For an empty file, seeing org.apache.commons.io.output.ThresholdingOutputStream checking threshold with an "greater than" operator (>),
      I guess "fac.setSizeThreshold(0);" does not actually make sure the data is written to a file (hence getting null storeLocation)

      See also https://issues.apache.org/jira/browse/WW-5088

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jeanjean KON-SUN-TACK
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: