Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0037238Openbravo ERPA. Platformpublic2017-11-07 10:502018-01-03 12:39
gorkaion 
caristu 
urgentminorhave not tried
closedfixed 
5
 
3.0PR18Q1 
alostale
Core
No
0037238: OBMessageUtils class fails generating the vars when there is no Request
When a java process is executed without any request. For example a background process that implements the Process interface. The OBMessageUtils fails to generate the exeception message if it needs to load a VariablesSecureApp instance.

The problem is that it is loading the vars using:
final VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();

Which throws a OBException in case the RequestContext has no session.
Modify a background process to generate a message using "parseTranslation(String text)"

check that it fails with a exception similar to this.

ERROR org.openbravo.base.exception.OBException - No request object set
org.openbravo.base.exception.OBException: No request object set
at org.openbravo.client.kernel.RequestContext.getVariablesSecureApp(RequestContext.java:167)
at org.openbravo.erpCommon.utility.OBMessageUtils.parseTranslation(OBMessageUtils.java:201)
The vars Object in OBMessageUtils methods is mainly used to load Session variables. The proposed solution is to initialize it only when it is needed in the translate() and translateError() methods and keep it null until then.
No tags attached.
? testIssue37238.dif (3,214) 2017-11-23 14:08
https://issues.openbravo.com/file_download.php?file_id=11317&type=bug
Issue History
2017-11-07 10:50gorkaionNew Issue
2017-11-07 10:50gorkaionAssigned To => platform
2017-11-07 10:50gorkaionModules => Core
2017-11-07 10:50gorkaionTriggers an Emergency Pack => No
2017-11-23 13:47caristuDescription Updatedbug_revision_view_page.php?rev_id=16355#r16355
2017-11-23 13:51caristuNote Added: 0100687
2017-11-23 14:08caristuFile Added: testIssue37238.dif
2017-11-23 14:08caristuNote Edited: 0100687bug_revision_view_page.php?bugnote_id=0100687#r16357
2017-11-23 14:08caristuStatusnew => acknowledged
2017-11-28 18:04hgbotCheckin
2017-11-28 18:04hgbotNote Added: 0100795
2017-11-28 18:04hgbotStatusacknowledged => resolved
2017-11-28 18:04hgbotResolutionopen => fixed
2017-11-28 18:04hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/698a79b5ee76f0ddcf63ccd2066d3281ae8ba5e4 [^]
2017-11-28 18:05caristuAssigned Toplatform => caristu
2017-11-28 19:00hgbotCheckin
2017-11-28 19:00hgbotNote Added: 0100798
2017-12-01 11:03alostaleReview Assigned To => alostale
2017-12-01 11:03alostaleNote Added: 0100883
2017-12-01 11:03alostaleStatusresolved => closed
2017-12-01 11:03alostaleFixed in Version => 3.0PR18Q1
2018-01-03 12:39hudsonbotCheckin
2018-01-03 12:39hudsonbotNote Added: 0101494
2018-01-03 12:39hudsonbotCheckin
2018-01-03 12:39hudsonbotNote Added: 0101495

Notes
(0100687)
caristu   
2017-11-23 13:51   
(edited on: 2017-11-23 14:08)
This issue can not be reproduced with background processes that extends DalBaseProcess, because they are already initializing the vars on their execute method[1]. Description has been updated.

[1] https://code.openbravo.com/erp/devel/pi/file/tip/src/org/openbravo/service/db/DalBaseProcess.java#l71 [^]

Attached a test case where the issue can be reproduced.

(0100795)
hgbot   
2017-11-28 18:04   
Repository: erp/devel/pi
Changeset: 698a79b5ee76f0ddcf63ccd2066d3281ae8ba5e4
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Tue Nov 28 18:01:43 2017 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/698a79b5ee76f0ddcf63ccd2066d3281ae8ba5e4 [^]

fixes bug 37238: OBMessageUtils fails on vars retrieval if there isn't request

  Two main changes:
    1- Postponed the vars initialization until it is really needed.
    2- If the vars retrieval fails because there is no request then the exception thrown in that case is now catched and then the message is tried to be loaded from database.

---
M src/org/openbravo/erpCommon/utility/OBMessageUtils.java
---
(0100798)
hgbot   
2017-11-28 19:00   
Repository: erp/devel/pi
Changeset: 07a264cb64e423af67528db8523434eb8dea99a7
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Tue Nov 28 18:59:16 2017 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/07a264cb64e423af67528db8523434eb8dea99a7 [^]

related to issue 37238: added test cases

---
M src-test/src/org/openbravo/test/scheduling/ProcessSchedulingTest.java
---
(0100883)
alostale   
2017-12-01 11:03   
reviewed + tested
(0101494)
hudsonbot   
2018-01-03 12:39   
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/c81e0d3cbab5 [^]
Maturity status: Test
(0101495)
hudsonbot   
2018-01-03 12:39   
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/c81e0d3cbab5 [^]
Maturity status: Test