Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0038188Openbravo ERPA. Platformpublic2018-03-21 11:292018-03-23 21:22
caristu 
caristu 
highminorhave not tried
closedfixed 
5
 
3.0PR18Q2 
alostale
Core
No
0038188: Concurrency problem when downloading attachments with attachment methods that downloads temp files
When downloading attachments with attachment methods that downloads temp files, the temporary file generated for an attachment is always generated with the attachment name.

This can cause problems if the same attachment is downloaded by different clients at the same time, as the temporary file is deleted at the end of the processes. Thus, if the temporary file is deleted and there is a client which is downloading the same attachment at that very same moment, it could result in the downloading of an empty/corrupted file.
Artificial test.

0) Install the following module[1] which contains an attachment method which uses temporary files on download. Configure it as the attachment method of the client.

1) Login in Openbravo. Create an attachment in any window.
2) In eclipse, put a breakpoint in this line: https://code.openbravo.com/erp/devel/pi/file/tip/modules/org.openbravo.client.application/src/org/openbravo/client/application/attachment/AttachImplementationManager.java#l267 [^]
3) Download the attachment. Stop at the breakpoint.
4) Login in Openbravo using another browser tab.
5) In eclipse, put a breakpoint in this line: https://code.openbravo.com/erp/devel/pi/file/tip/modules/org.openbravo.client.application/src/org/openbravo/client/application/attachment/AttachImplementationManager.java#l264 [^]
6) Download the same attachment of step 3. Stop at the breakpoint.
7) Continue the thread stopped at step 3 --> The attachment is correctly downloaded
8) Continue with the thread stopped at step 6 --> ERROR. The attachment is not correctly downloaded (an empty file is downloaded)

[1] https://code.openbravo.com/erp/pmods/org.openbravo.service.integration.amazon.s3 [^]
No tags attached.
related to defect 0038450 closed caristu Allow to download attachments in temporary files using the attachment name without concurrency problems 
blocks design defect 0034664 acknowledged Triage Platform Base multi thread unsafeties 
Issue History
2018-03-21 11:29caristuNew Issue
2018-03-21 11:29caristuAssigned To => platform
2018-03-21 11:29caristuModules => Core
2018-03-21 11:29caristuTriggers an Emergency Pack => No
2018-03-21 11:29caristuSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=16902#r16902
2018-03-21 11:29caristuAssigned Toplatform => caristu
2018-03-21 13:11caristuDescription Updatedbug_revision_view_page.php?rev_id=16904#r16904
2018-03-21 13:56hgbotCheckin
2018-03-21 13:56hgbotNote Added: 0103387
2018-03-21 13:56hgbotStatusnew => resolved
2018-03-21 13:56hgbotResolutionopen => fixed
2018-03-21 13:56hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/922ddf36e81c56a1320e2d9b66ecd6c54988be5c [^]
2018-03-21 13:56caristuReview Assigned To => alostale
2018-03-22 12:02alostaleRelationship addedblocks 0034664
2018-03-22 15:09hudsonbotCheckin
2018-03-22 15:09hudsonbotNote Added: 0103431
2018-03-23 08:52hgbotCheckin
2018-03-23 08:52hgbotNote Added: 0103456
2018-03-23 09:05alostaleNote Added: 0103457
2018-03-23 09:05alostaleStatusresolved => closed
2018-03-23 09:05alostaleFixed in Version => 3.0PR18Q2
2018-03-23 21:22hudsonbotCheckin
2018-03-23 21:22hudsonbotNote Added: 0103477
2018-04-25 15:48caristuRelationship addedrelated to 0038450

Notes
(0103387)
hgbot   
2018-03-21 13:56   
Repository: erp/devel/pi
Changeset: 922ddf36e81c56a1320e2d9b66ecd6c54988be5c
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Wed Mar 21 13:51:33 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/922ddf36e81c56a1320e2d9b66ecd6c54988be5c [^]

fixes issue 38188: avoid concurrency problems in attachment download

  When using an attachment method that creates a temporary (copy) of an attached file about to be downloaded, that copy is deleted once it has been served. Using the attachment name as the name for this "copied" file can cause concurrency problems when the same attachment is downloaded at the same time by different users.

  To avoid this poblem, now the file to be served will be created in the server with the same name of the file returned by the attachment method. Note that this change does not affect to the name of the file that will be downloaded in the client, which still will be the name of the attachment.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/attachment/AttachImplementationManager.java
---
(0103431)
hudsonbot   
2018-03-22 15:09   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/3e905f6a2434 [^]
Maturity status: Test
(0103456)
hgbot   
2018-03-23 08:52   
Repository: erp/devel/pi
Changeset: adf483c880661502b713d122fc638a2e9a26b568
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Fri Mar 23 08:51:41 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/adf483c880661502b713d122fc638a2e9a26b568 [^]

related to issue 38188: use NIO API to copy the file into the output stream

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/attachment/AttachImplementationManager.java
---
(0103457)
alostale   
2018-03-23 09:05   
reviewed
(0103477)
hudsonbot   
2018-03-23 21:22   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/42e5233f5207 [^]
Maturity status: Test