You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (Jira)" <ji...@apache.org> on 2021/11/12 14:14:00 UTC

[jira] [Resolved] (WW-5146) Empty file upload ends in error

     [ https://issues.apache.org/jira/browse/WW-5146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart resolved WW-5146.
-------------------------------
    Resolution: Duplicate

> Empty file upload ends in error
> -------------------------------
>
>                 Key: WW-5146
>                 URL: https://issues.apache.org/jira/browse/WW-5146
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>    Affects Versions: 2.5.26
>            Reporter: KON-SUN-TACK
>            Priority: Minor
>              Labels: upload
>             Fix For: 2.6
>
>
> 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:
> {code:java}
> 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;
>  }
> {code}
>  
> 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



--
This message was sent by Atlassian Jira
(v8.20.1#820001)