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

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0033138
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] A. Platformminorhave not tried2016-06-05 14:542016-08-26 08:07
ReportershuehnerView Statuspublic 
Assigned Toalostale 
PrioritynormalResolutionfixedFixed in Version3.0PR16Q3
StatusclosedFix in branchFixed in SCM revisionec3e4492a91c
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Tocaristu
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0033138: OBCriteria.initialize() is not protected against multiple calls per instance

DescriptionOBCriteria has an internal initialize() method which adds the usual client,org,isactive filters.

However that initialize() method is not protected against multiple calls per instance.

So calling it more than once adds those filters also multiple times.

Several are at least 2 sequences triggering this
a.) call .count() + .uniqueResult() manually from application as seen i.e. in WebPOS OrderLoader:
    final OBCriteria<Locator> locators = OBDal.getInstance().createCriteria(Locator.class);
    locators.add(Restrictions.eq(Locator.PROPERTY_ACTIVE, true));
    locators.add(Restrictions.eq(Locator.PROPERTY_WAREHOUSE, shipment.getWarehouse()));
    // note the count causes a query but the good thing is that it doesn't cause loading
    // additional bin locations if there are too many
    if (locators.count() == 1) {
      foundSingleBin = (Locator) locators.uniqueResult();

b.) But also .count() implementation itself calls initialize() and then uniqueResult() (calling it again).

Steps To ReproduceTrace all SQL's done by OrderLoader starting at part in createShipmentLines
    if (locators.count() == 1) {
      foundSingleBin = (Locator) locators.uniqueResult();

That SQL run by the .count() already has 3 blocks of the client+org filters happening (2 copies by this bug) + additional one reported as issue 33132.

Then the next SQL run by the manual uniqueResult added 2 more copies of the filters. (one by itself and maybe 2nd one because of that same 33132).
Proposed SolutionAdd isInitialized boolean or similar to OBCriteria.initialize()
TagsPerformance
Attached Files

- Relationships Relation Graph ] Dependency Graph ]
related to defect 0033816 closedcaristu Find a complete solution to protect OBCriteria.initialize() against multiple calls per instance 
has duplicate defect 0033132 closedplatform OBCriteria (at least sometimes) add client + org filters twice 
causes defect 0033797 closedTriage Omni OMS Product selector in sales order lines, don't take the last price list version 
causes defect 00338143.0PR16Q4 closedcaristu Initialization in OBCriteria should not be prevented under some circumstances 

-  Notes
(0087034)
shuehner (administrator)
2016-06-06 15:13

shuehner (administrator)
2016-06-06 15:12

Later checking shows that even just calling uniqueResult() internally falls back to .list() so doing double init already.

Example calling sequence:
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
    at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
    at org.openbravo.dal.service.OBCriteria.list(OBCriteria.java:90)
    at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:369)
    at org.openbravo.dal.service.OBCriteria.uniqueResult(OBCriteria.java:129)
    at org.openbravo.dal.service.OBCriteria.count(OBCriteria.java:103)

And each of count + uniqueResult + list of the OBCriteria calls initialize()
(0087147)
hgbot (developer)
2016-06-10 09:59

Repository: erp/devel/pi
Changeset: ec3e4492a91c88e84d09e34b9e3e487f13ad3cb8
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Fri Jun 10 09:58:42 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/ec3e4492a91c88e84d09e34b9e3e487f13ad3cb8 [^]

fixed bug 33138: OBCriteria adds standard filters several times

  In some cases (ie. in count method), OBCriteria adds the standard filters for
  client, org and active several times.

  The problem was caused because initialize method can be invoked several times
  on the same criteria instance adding each time those filters.

  Fixed now by setting a flag on 1st initialization and checking it to prevent
  subsequent ones. Note this flag is not thread safe, but in any case OBCriteria
  was not safe before it: several parallel initialization could clash.

---
M src/org/openbravo/dal/service/OBCriteria.java
---
(0087380)
caristu (developer)
2016-06-17 09:26

Verified

Reviewed in pi@a3288a6ce595
(0087601)
hudsonbot (developer)
2016-06-17 19:38

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/0dc7be081b1c [^]
Maturity status: Test

- Issue History
Date Modified Username Field Change
2016-06-05 14:54 shuehner New Issue
2016-06-05 14:54 shuehner Assigned To => platform
2016-06-05 14:54 shuehner Modules => Core
2016-06-05 14:54 shuehner Triggers an Emergency Pack => No
2016-06-05 14:54 shuehner Relationship added related to 0033132
2016-06-05 15:14 shuehner Tag Attached: page data grid
2016-06-05 15:14 shuehner Tag Attached: Performance
2016-06-05 15:14 shuehner Tag Detached: page data grid
2016-06-06 15:13 shuehner Note Added: 0087034
2016-06-08 13:33 shuehner Relationship replaced has duplicate 0033132
2016-06-10 09:54 alostale Assigned To platform => alostale
2016-06-10 09:54 alostale Review Assigned To => caristu
2016-06-10 09:59 hgbot Checkin
2016-06-10 09:59 hgbot Note Added: 0087147
2016-06-10 09:59 hgbot Status new => resolved
2016-06-10 09:59 hgbot Resolution open => fixed
2016-06-10 09:59 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/ec3e4492a91c88e84d09e34b9e3e487f13ad3cb8 [^]
2016-06-17 09:26 caristu Note Added: 0087380
2016-06-17 09:26 caristu Status resolved => closed
2016-06-17 09:26 caristu Fixed in Version => 3.0PR16Q3
2016-06-17 19:38 hudsonbot Checkin
2016-06-17 19:38 hudsonbot Note Added: 0087601
2016-08-25 13:10 caristu Relationship added causes 0033797
2016-08-25 15:56 shuehner Relationship added causes 0033814
2016-08-25 16:18 caristu Issue cloned 0033816
2016-08-25 17:24 shuehner Issue Monitored: shuehner
2016-08-26 08:07 caristu Relationship added related to 0033816


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker