Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0020097Openbravo ERP09. Financial managementpublic2012-03-23 12:502012-04-02 13:57
eduardo_Argal 
mirurita 
urgentmajorsometimes
closedfixed 
5
 
 
Core
No
0020097: java.lang.StackOverflowError as infinite loop occurs while calling OrganizationStructureProvider
An infinite loop results into java.lang.StackOverflowError.
1) Install remittance module
2) create a new remittance header for organization F&B US, Inc.
3) click on Select orders or invoices (Now it will work fine)
4) open Payment in and create a new header using organization F&B US, Inc.
5) Click on Add Details (It will work fine as well)
6) move back to remittance and click again in Select orders or invoices

Realize that now java.lang.StackOverflowError occurs doing the same call than in step 3
Regression
related to defect 00192603.0MP8 closed jecharri You can use credit generated from other organization with a common Business Partner 
Issue History
2012-03-23 12:50eduardo_ArgalNew Issue
2012-03-23 12:50eduardo_ArgalAssigned To => vmromanos
2012-03-23 12:50eduardo_ArgalModules => Core
2012-03-23 12:52vmromanosStatusnew => scheduled
2012-03-23 12:52vmromanosfix_in_branch => pi
2012-03-23 14:07vmromanosReproducibilityalways => sometimes
2012-03-23 14:07vmromanosfix_in_branchpi =>
2012-03-27 21:40miruritaAssigned Tovmromanos => mirurita
2012-03-27 22:24hgbotCheckin
2012-03-27 22:24hgbotNote Added: 0046791
2012-03-27 22:24hgbotStatusscheduled => resolved
2012-03-27 22:24hgbotResolutionopen => fixed
2012-03-27 22:24hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/bd5c72a00d0f6d25f8a77a721548cd9cba740daa [^]
2012-03-27 22:25miruritaNote Added: 0046792
2012-03-28 10:57vmromanosNote Added: 0046808
2012-03-28 10:57vmromanosStatusresolved => closed
2012-03-28 10:57vmromanosFixed in Version => 3.0MP9
2012-04-01 20:34hgbotCheckin
2012-04-01 20:34hgbotNote Added: 0047022
2012-04-01 20:34hgbotStatusclosed => resolved
2012-04-01 20:34hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/bd5c72a00d0f6d25f8a77a721548cd9cba740daa [^] => http://code.openbravo.com/erp/devel/pi/rev/eac99d3aee34bbe62abe5e78a1698d663c19b3f6 [^]
2012-04-02 06:12hudsonbotCheckin
2012-04-02 06:12hudsonbotNote Added: 0047249
2012-04-02 12:17gorka_gilNote Added: 0047301
2012-04-02 12:17gorka_gilStatusresolved => closed
2012-04-02 13:43dmitry_mezentsevTag Attached: Regression
2012-04-02 13:56miruritaStatusclosed => new
2012-04-02 13:56miruritaResolutionfixed => open
2012-04-02 13:56miruritaFixed in Version3.0MP9 =>
2012-04-02 13:56miruritaRelationship addedrelated to 0019260
2012-04-02 13:57miruritaStatusnew => scheduled
2012-04-02 13:57miruritafix_in_branch => pi
2012-04-02 13:57miruritaStatusscheduled => resolved
2012-04-02 13:57miruritaResolutionopen => fixed
2012-04-02 13:57miruritaStatusresolved => closed
2012-04-02 13:57miruritaNote Added: 0047312

Notes
(0046791)
hgbot   
2012-03-27 22:24   
Repository: erp/devel/pi
Changeset: bd5c72a00d0f6d25f8a77a721548cd9cba740daa
Author: Mikel Irurita <mikel.irurita <at> openbravo.com>
Date: Tue Mar 27 22:23:41 2012 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/bd5c72a00d0f6d25f8a77a721548cd9cba740daa [^]

Fixes issue 20097: java.lang.StackOverflowError while calling OrganizationStructureProvider

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java
---
(0046792)
mirurita   
2012-03-27 22:25   
OBContext.getOBContext().getOrganizationStructureProvider().getChildOrg(legalEntity.getId())
returned a reference to the private class attribute childByOrganizationID.
So, if you modify returned value you are actually modifying the "global" object, because is a reference to the same instance.
The following line
orgIds.add(legalEntity.getId());
was adding the parent org to the children org list.
So, if after executing the previous code you call to getChildOrg method which does recursive calls to get the full list of child orgs it results in a infinite loop because the parent or is contained in the child org list.
This was causing the stack overflow error.
 
Methods returning references to the class attributes (and not a new instance) should be reviewed. Any external module can use our public API and create corrupted data.
More info: https://issues.openbravo.com/view.php?id=20129 [^]

Testing plan:

Basic:
1) Create a new Payment
2) Click on Add details button. At this point the childByOrganizationID object should containg invalid data.
3) Execute any code that calls to getChildTree method on OrganizationStructureProvider. For example create a new remittance and click in Select orders or invoices

Other affected areas:

The modified method is called from the following flows:
- Processing a payment with used credit different to zero.
- Completing an invoice and the business partner of the invoice has credit to consume. A popup should be displayed where the user can consume the available credit.
- Click 'Add details' button in Payment In/Out window. The header must have a business partner.
- Add payment from invoice. Click on 'Add Payment In/Out' from invoice.
- Add payment from transaction.

Execute previous flows.
(0046808)
vmromanos   
2012-03-28 10:57   
code review + testing OK

Tested using proposed testing plans by mirurita
(0047022)
hgbot   
2012-04-01 20:34   
Repository: erp/devel/pi
Changeset: eac99d3aee34bbe62abe5e78a1698d663c19b3f6
Author: Mikel Irurita <mikel.irurita <at> openbravo.com>
Date: Tue Mar 27 22:23:41 2012 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/eac99d3aee34bbe62abe5e78a1698d663c19b3f6 [^]

Fixes issue 20097: java.lang.StackOverflowError while calling OrganizationStructureProvider

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java
---
(0047249)
hudsonbot   
2012-04-02 06: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/7814864461ac [^]

Maturity status: Test
(0047301)
gorka_gil   
2012-04-02 12:17   
Reopened by merge.
(0047312)
mirurita   
2012-04-02 13:57   
Regression introduced by 0019260.