Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0049374Openbravo ERPA. Platformpublic2022-05-23 10:322022-05-30 12:48
alostale 
Triage Platform Base 
normalminorhave not tried
acknowledgedopen 
5
 
 
Core
Production - Confirmed Stable
2020-07-20
PR20Q2.2
https://gitlab.com/openbravo/product/openbravo/-/commit/1cc1f00fa6db5780ba858122a87f1485d8d402e3 [^]
No
0049374: cannot upload a file to a location that already exists
It is not longer possible upload a file (using org.apache.commons.fileupload.disk.DiskFileItem) if the destination file already exists.

The current commons-fileupload version (1.4) has a regression [1] that prevents it.

This would occur, for example, in this piece of code:

      File tmpFile = File.createTempFile("myFile", "tmp");
      fileItem.write(tmpFile);


---

[1] https://issues.apache.org/jira/browse/FILEUPLOAD-293 [^]
Execute this piece of code (where fileItem is some file uploaded by the user):

      File tmpFile = File.createTempFile("myFile", "tmp");
      fileItem.write(tmpFile);


ERROR:
org.apache.commons.io.FileExistsException: Destination '/tmp/myFileES12761645902496824351tmp' already exists
    at org.apache.commons.io.FileUtils.moveFile(FileUtils.java:2825) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.fileupload.disk.DiskFileItem.write(DiskFileItem.java:405) ~[commons-fileupload-1.4.jar:1.4]
Although Apache Commons FileUpload project has fixed the issue in their code repositories [1], they have not published a new version including this fix. Furthermore, according with the discussions in the issue report [2], it seems
they are not planning to do so in a foreseeable future.

So, for now, the temporary workaround is to change the code invoking the affected method to ensure the file does not exist, similarly to what they are doing in their fix [3]:


      File tmpFile = File.createTempFile("myFile", "tmp");
      tmpFile.delete();
      fileItem.write(tmpFile);


---
[1] https://github.com/apache/commons-fileupload/commit/5c2302bbf3859aabf3a719285237f6d0773612b2. [^]
[2] https://issues.apache.org/jira/browse/FILEUPLOAD-293 [^]
[3] https://github.com/apache/commons-fileupload/commit/5c2302bbf3859aabf3a719285237f6d0773612b2#diff-0b9a284d7c4709ab8da7e3de061e2019e68f3a9d597d972bd4b54f4dbd8c2e63R405-R407 [^]
No tags attached.
caused by feature request 0044937 closed caristu Update fileUpload library 
Issue History
2022-05-23 10:32alostaleNew Issue
2022-05-23 10:32alostaleAssigned To => Triage Platform Base
2022-05-23 10:32alostaleModules => Core
2022-05-23 10:32alostaleTriggers an Emergency Pack => No
2022-05-23 10:33alostaleRelationship addedcaused by 0044937
2022-05-23 10:34alostaleRegression date => 2020-07-20
2022-05-23 10:34alostaleRegression introduced in release => PR20Q2.2
2022-05-23 10:34alostaleRegression introduced by commit => https://gitlab.com/openbravo/product/openbravo/-/commit/1cc1f00fa6db5780ba858122a87f1485d8d402e3 [^]
2022-05-23 10:34alostaleRegression level => Production - Confirmed Stable
2022-05-23 14:27alostaleNote Added: 0137633
2022-05-23 14:27alostaleTypedefect => design defect
2022-05-30 12:23AugustoMauchAssigned ToTriage Platform Base => meriem_azaf
2022-05-30 12:23AugustoMauchStatusnew => acknowledged
2022-05-30 12:47AugustoMauchAssigned Tomeriem_azaf => Triage Platform Base
2022-05-30 12:47AugustoMauchStatusacknowledged => scheduled
2022-05-30 12:48AugustoMauchStatusscheduled => acknowledged

Notes
(0137633)
alostale   
2022-05-23 14:27   
Moved to design defect as it is depends on a new version of the Apache Commons FileUpload that is unlikely to be released in short