Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0022235Openbravo ERPA. Platformpublic2012-11-08 11:192013-01-03 13:12
caristu 
mtaal 
urgentmajoralways
closedfixed 
5
 
3.0MP193.0MP19 
AugustoMauch
Core
No
0022235: OBMessageUtils asumes incorrectly that RequestContext is set
If you extend a class from DalProcess and you call call RequestContext.get().getVariablesSecureApp(); it returns null.

So for example, if you use any of the public methods of OBMessageUtils() that uses the previous statement, the process crashes because we are obtaining a null reference. For example, the translateError() method is using this practise:

public static OBError translateError(String message) {
  VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
  final String strLanguage = OBContext.getOBContext().getLanguage().getLanguage();
return translateError(new DalConnectionProvider(false), vars, strLanguage, message);
}

So, we can't use this approach, instead we must use the ProcessBudle class to obtain the vars variable: bundle.getContext().toVars();
- Create a new process extending DalBaseProcess class
- Try to use any of the methods of OBMessageUtils() that uses RequestContext(), for example the translateError() method
The current implementation of OBMessageUtils incorrectly uses the RequestContext, assuming that it is always set. Proposed Solutions:

- deprecate this OBMessageUtils method or remove it (api change)
- add an abstraction for RequestContext that only provides the things common to process threads and http request threads (like VariablesSecureApp) and then use this ThreadContext object in all the places in core where RequestContext is being used.
No tags attached.
related to defect 00248323.0MP29 closed shankarb EntityPersistenceEventObserver: cascade errors from ProcessBundle are not displayed 
Issue History
2012-11-08 11:19caristuNew Issue
2012-11-08 11:19caristuAssigned To => AugustoMauch
2012-11-08 11:19caristuModules => Core
2012-11-08 11:19caristuResolution time => 1355094000
2012-11-19 17:09AugustoMauchAssigned ToAugustoMauch => shankarb
2012-11-21 11:31shankarbAssigned Toshankarb => AugustoMauch
2012-12-04 12:39AugustoMauchTarget Version3.0MP18 => 3.0MP19
2012-12-10 14:28mtaalAssigned ToAugustoMauch => mtaal
2012-12-27 08:23mtaalReview Assigned To => AugustoMauch
2012-12-27 08:23mtaalTriggers an Emergency Pack => No
2012-12-27 08:23mtaalNote Added: 0055229
2012-12-27 08:26hgbotCheckin
2012-12-27 08:26hgbotNote Added: 0055230
2012-12-27 08:26hgbotStatusnew => resolved
2012-12-27 08:26hgbotResolutionopen => fixed
2012-12-27 08:26hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/f2eb38f962af844d217dd50974a355521094841c [^]
2012-12-27 08:27hgbotCheckin
2012-12-27 08:27hgbotNote Added: 0055231
2013-01-02 11:05AugustoMauchNote Added: 0055303
2013-01-02 11:05AugustoMauchStatusresolved => closed
2013-01-02 11:05AugustoMauchFixed in Version => 3.0MP19
2013-01-03 13:12hudsonbotCheckin
2013-01-03 13:12hudsonbotNote Added: 0055325
2013-01-03 13:12hudsonbotCheckin
2013-01-03 13:12hudsonbotNote Added: 0055326
2013-09-25 17:51vmromanosRelationship addedrelated to 0024832

Notes
(0055229)
mtaal   
2012-12-27 08:23   
For now I decided to re-use the RequestContext class. It is a fine class for this purpose and RequestContext and ThreadContext are very similar concepts.

This also means the least changes in the code.
(0055230)
hgbot   
2012-12-27 08:26   
Repository: erp/devel/pi
Changeset: f2eb38f962af844d217dd50974a355521094841c
Author: Martin Taal <martin.taal <at> openbravo.com>
Date: Thu Dec 27 08:24:46 2012 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/f2eb38f962af844d217dd50974a355521094841c [^]

Fixes issue 22235: OBMessageUtils asumes incorrectly that RequestContext is set
Set variables secure app in RequestContext in case of running a process

---
M modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/RequestContext.java
M src-test/org/openbravo/test/dal/IssuesTest.java
M src/org/openbravo/service/db/DalBaseProcess.java
---
(0055231)
hgbot   
2012-12-27 08:27   
Repository: erp/devel/pi
Changeset: 4fd1d28743f189e4d94949af1a02e68d72d82d30
Author: Martin Taal <martin.taal <at> openbravo.com>
Date: Thu Dec 27 08:27:09 2012 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/4fd1d28743f189e4d94949af1a02e68d72d82d30 [^]

Related to issue 22235: OBMessageUtils asumes incorrectly that RequestContext is set

---
M src-test/org/openbravo/test/dal/IssuesTest.java
---
(0055303)
AugustoMauch   
2013-01-02 11:05   
Code reviewed and verified in pi@6735d51a4790
(0055325)
hudsonbot   
2013-01-03 13:12   
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/792728467ed0 [^]

Maturity status: Test
(0055326)
hudsonbot   
2013-01-03 13:12   
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/792728467ed0 [^]

Maturity status: Test