Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0045428
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Localization Pack: Spain] SIImajorhave not tried2020-11-11 18:022020-12-16 11:15
ReportershuehnerView Statuspublic 
Assigned ToMery Anelo 
PrioritynormalResolutionfixedFixed in Version
StatusclosedFix in branchFixed in SCM revision
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Regression date
Regression introduced by commit
Regression level
Review Assigned To
Regression introduced in release
Summary

0045428: FacturasEventHandler -> SIIUtils.getLegalOrganization has setAdminMode but never calls restorePreviousMode

DescriptionFound via many Junit tests from backoffice failing with

Test case should take care of reseting admin mode correctly in a finally block, use OBContext.restorePreviousMode

when having org.openbravo.module.sii template installed.

For example
org.openbravo.test.costing.TestCostingSourceAdjustments.testCostingAAA
(around 60-70 in total)

Debugging this points to SIIUtils.getLegalOrganization utility Function called via FacturasEventHandler

    at org.openbravo.dal.core.OBContext.addStackTrace(OBContext.java:362)
    at org.openbravo.dal.core.OBContext.setAdminMode(OBContext.java:223)
    at org.openbravo.module.sii.utils.SIIUtils.getLegalOrganization(SIIUtils.java:308)
    at org.openbravo.module.sii.eventhandlers.FacturasEventHandler.checkInvoice(FacturasEventHandler.java:116)
    at org.openbravo.module.sii.eventhandlers.FacturasEventHandler.onUpdate(FacturasEventHandler.java:68)

Reviewing that function shows it uses setAdminMode but does never restorePreviousMode violating calling convention to always use those in pairs (typically with a finally block)



Steps To ReproduceFound in specific customer instance but probably following is enough:

a.) Backoffice environment (testing in release/20Q4 branch)
b.) Add sii module
c.) run junit tests.
c.1) For example the following tests showcases the problem:
org.openbravo.test.createlinesfrom.CreateLinesFromTest
Proposed SolutionReview code and fix calling convention for adminMode by using the typical recommended pattern.

OBContext.setAdminMode(bool)
try {
  <code running with adminMode>
} finally {
  OBContext.restorePreviousMode();
}
TagsNo tags attached.
Attached Filesdiff file icon 45428.diff [^] (676 bytes) 2020-11-11 18:47 [Show Content]

- Relationships Relation Graph ] Dependency Graph ]
related to defect 0045429 closedshuehner Openbravo ERP Code to detect+warn about Unbalanced adminMode in OBBaseTest should be improved 

-  Notes
(0124284)
shuehner (administrator)
2020-11-11 18:03

Note: Quick check on that SIIUtils.java class shows the same issue being present not just in this utility function but also in many others.

So apart from fixing this specific case probably the whole file (or module should be reviewed)
(0124285)
shuehner (administrator)
2020-11-11 18:47

Attached patch is enough to fix the issue as reported affecting unrelated junit tests.
Maybe reviewing the other wrong methods should be split out into separate issue to not delay fixing this first problem.
(0124602)
Mery Anelo (developer)
2020-11-24 23:56

Test plan:

- From the back office
- Run JUnit test org.openbravo.test.createlinesfrom.CreateLinesFromTest
- Check that there is no WARNING for Unbalanced calls to setAdminMode and restorePreviousMode.

- Make use and check the modified methods. Verify that WARNING for Unbalanced calls to setAdminMode and restorePreviousMode is not recorded in the log.
(0124603)
hgbot (developer)
2020-11-24 23:57

Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.module.sii/-/merge_requests/6 [^]
(0124877)
hgbot (developer)
2020-12-16 11:15

Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.module.sii [^]
Changeset: fde69d1ccdf3661df161ebd5f6e7b9831f8c878f
Author: Mery Anelo <mery.anelo@smfconsulting.es>
Date: 2020-11-24T18:21:23-03:00
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.module.sii/-/commit/fde69d1ccdf3661df161ebd5f6e7b9831f8c878f [^]

Fixed issue 45428: Unbalanced AdminMode and RestorePreviousMode.

Balance admin modes and their respective restores.

---
M src/org/openbravo/module/sii/process/ConsultaFactura.java
M src/org/openbravo/module/sii/process/CorrectDuplicateInvoiceError.java
M src/org/openbravo/module/sii/process/MultiCashReceiptSIIModification.java
M src/org/openbravo/module/sii/process/MultiCashReceiptSending.java
M src/org/openbravo/module/sii/process/MultiEnvioFactura.java
M src/org/openbravo/module/sii/process/MultiInvoiceSIIModification.java
M src/org/openbravo/module/sii/process/MultiPaymentSending.java
M src/org/openbravo/module/sii/process/MultiUnsubscribeInvoice.java
M src/org/openbravo/module/sii/process/PaymentSending.java
M src/org/openbravo/module/sii/process/UpdateInvoicesPreSii.java
M src/org/openbravo/module/sii/process/background/CorrectDuplicateInvoiceErrorBackground.java
M src/org/openbravo/module/sii/process/background/SendInvoicesGroupsToAEAT.java
M src/org/openbravo/module/sii/utils/SIIUtils.java
---
(0124878)
hgbot (developer)
2020-12-16 11:15

Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.module.sii [^]
Changeset: f8ffdc786234065a129e27a4b89b011082f6a4b5
Author: Mery Anelo <mery.anelo@smfconsulting.es>
Date: 2020-11-24T18:36:22-03:00
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.module.sii/-/commit/f8ffdc786234065a129e27a4b89b011082f6a4b5 [^]

Fixed issue 45428: Format java.

Without changes, the java is simply formatted according to the corresponding indentation.

---
M src/org/openbravo/module/sii/process/MultiCashReceiptSIIModification.java
M src/org/openbravo/module/sii/process/MultiCashReceiptSending.java
M src/org/openbravo/module/sii/process/MultiEnvioFactura.java
M src/org/openbravo/module/sii/process/MultiInvoiceSIIModification.java
M src/org/openbravo/module/sii/process/MultiPaymentSending.java
M src/org/openbravo/module/sii/process/background/CorrectDuplicateInvoiceErrorBackground.java
M src/org/openbravo/module/sii/utils/SIIUtils.java
---
(0124879)
hgbot (developer)
2020-12-16 11:15

Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.module.sii/-/merge_requests/6 [^]

- Issue History
Date Modified Username Field Change
2020-11-11 18:02 shuehner New Issue
2020-11-11 18:02 shuehner Assigned To => Jorge Bravo
2020-11-11 18:03 shuehner Note Added: 0124284
2020-11-11 18:27 shuehner Relationship added related to 0045429
2020-11-11 18:47 shuehner File Added: 45428.diff
2020-11-11 18:48 shuehner Note Added: 0124285
2020-11-12 08:17 Jorge Bravo Assigned To Jorge Bravo => Mery Anelo
2020-11-24 23:56 Mery Anelo Note Added: 0124602
2020-11-24 23:57 hgbot Note Added: 0124603
2020-11-25 00:01 Mery Anelo Status new => scheduled
2020-12-16 11:15 hgbot Resolution open => fixed
2020-12-16 11:15 hgbot Status scheduled => closed
2020-12-16 11:15 hgbot Note Added: 0124877
2020-12-16 11:15 hgbot Note Added: 0124878
2020-12-16 11:15 hgbot Note Added: 0124879


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker