[
https://issues.apache.org/jira/browse/WW-5146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17433621#comment-17433621
]
KON-SUN-TACK commented on WW-5146:
----------------------------------
Just noticed [this commit|https://github.com/apache/struts/commit/5eaa735]
which should fix the issue
> 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
>
> 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.3.4#803005)