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

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0041215
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Modules] Advanced Paymentsmajoralways2019-07-01 19:182019-08-22 14:45
ReportermartinsdanView Statuspublic 
Assigned Todmiguelez 
PrioritynormalResolutionfixedFixed in Version
StatusclosedFix in branchFixed in SCM revision89ffba6ba6bf
ProjectionnoneETAnoneTarget Version
OSLinux 64 bitDatabasePostgreSQLJava version11
OS Version18.01Database version9.5Ant version
Product VersionSCM revision 
Regression date
Regression introduced by commit
Regression level
Review Assigned Todmiguelez
Regression introduced in release
Summary

0041215: Error using FIN_Utility.getDocumentNo in an event handler

DescriptionAn error occurs when FIN_Utility.getDocumentNo is called for a sequence that is referenced in the entity being saved.
When this is done, an NPE will happen in hibernate.

2019-07-01 17:50:38,961 [http-nio-8080-exec-3] ERROR org.openbravo.service.json.DefaultJsonDataService - Error updating object
java.lang.NullPointerException: null
    at org.hibernate.type.descriptor.java.AbstractTypeDescriptor.extractHashCode(AbstractTypeDescriptor.java:78) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
    at org.hibernate.type.AbstractStandardBasicType.getHashCode(AbstractStandardBasicType.java:204) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
    at org.hibernate.type.AbstractStandardBasicType.getHashCode(AbstractStandardBasicType.java:209) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
    at org.hibernate.engine.spi.CollectionKey.generateHashCode(CollectionKey.java:64) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
    at org.hibernate.engine.spi.CollectionKey.<init>(CollectionKey.java:58) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
    at org.hibernate.engine.spi.CollectionKey.<init>(CollectionKey.java:33) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
    at org.hibernate.event.internal.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:400) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
    at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:40) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
    at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1454) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
    at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1440) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
    at org.openbravo.dal.service.OBDal.flush(OBDal.java:266) ~[classes/:?]
    at org.openbravo.service.json.DefaultJsonDataService.update(DefaultJsonDataService.java:1034) [classes/:?]
    at org.openbravo.service.datasource.DefaultDataSourceService.update(DefaultDataSourceService.java:239) [classes/:?]
    at org.openbravo.service.datasource.DataSourceServlet.doPut(DataSourceServlet.java:949) [classes/:?]
Steps To Reproduce- Add a sequence field in Product.
- Create an event handler for Product
- On save, call FIN_Utility.getDocumentNo and set the current state of the search key

The error will be shown
Proposed SolutionThe problem is related to the call of lockSequence(seq) in getDocumentNo.
I think the specific problem is OBDal.getInstance().getSession().evict(seq).

TagsNo tags attached.
Attached Files? file icon ProductKeyfromSequenceEventHandler.java [^] (2,516 bytes) 2019-07-02 12:51

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
(0113650)
AugustoMauch (developer)
2019-07-25 17:08

I have not been able to reproduce the issue in a clean pi environment after:
- Adding a new field to m_product that references an ad_sequence
- Adding an event handler to product trying both:
    * directly evicting its ad_sequence when the product is saved
    * calling FIN_Utility.getDocumentNo, which implicitely will end up evicting the sequence.

In all cases the update was done properly.

In the client test environment the issue was reproducible, unless the eviction of the sequence [1] was commented out.

Is this eviction needed? This other method [1] that locks an order does not need to evict is from the hibernate session.

[1] https://code.openbravo.com/erp/devel/pi/file/tip/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java#l407 [^]
[2] https://code.openbravo.com/erp/devel/pi/file/tip/src/org/openbravo/erpCommon/businessUtility/CancelAndReplaceUtils.java#l1662 [^]
(0113733)
dmiguelez (developer)
2019-07-31 12:49

Test plan.

It has not been possible to reproduce this issue locally due to the lack of the customization code and client's data.

It has been tested in the client and the related automated tests have been executed successfully.
(0113892)
hgbot (developer)
2019-08-08 08:26

Repository: erp/devel/pi
Changeset: 89ffba6ba6bf5d3b7d82b54c889de99a12e54f39
Author: Armaignac <collazoandy4 <at> gmail.com>
Date: Wed Jul 31 12:46:44 2019 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/89ffba6ba6bf5d3b7d82b54c889de99a12e54f39 [^]

Fixes issue 41215:Error using FIN_Utility.getDocumentNo in an event handler

An error occurs when FIN_Utility.getDocumentNo is called for a sequence that is
referenced in the entity being saved. When this is done, an NPE will happen in hibernate.

The problem is related to the call of lockSequence(seq) in getDocumentNo.
The specific problem is OBDal.getInstance().getSession().evict(seq)

The evict call was removed and also some code refactor was done

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java
---
(0113893)
dmiguelez (developer)
2019-08-08 08:26

Code Review + Testing Ok
(0114217)
hudsonbot (developer)
2019-08-22 14:45

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

- Issue History
Date Modified Username Field Change
2019-07-01 19:18 martinsdan New Issue
2019-07-01 19:18 martinsdan Assigned To => Triage Finance
2019-07-02 12:51 santi_lozano File Added: ProductKeyfromSequenceEventHandler.java
2019-07-02 13:02 egoitz Assigned To Triage Finance => platform
2019-07-02 13:03 egoitz Severity minor => major
2019-07-17 11:00 martinsdan Issue Monitored: martinsdan
2019-07-25 17:08 AugustoMauch Note Added: 0113650
2019-07-25 17:08 AugustoMauch Status new => feedback
2019-07-25 17:08 AugustoMauch Assigned To platform => martinsdan
2019-07-25 17:45 AugustoMauch Assigned To martinsdan => Triage Finance
2019-07-31 12:49 dmiguelez Note Added: 0113733
2019-08-06 11:54 Sandrahuguet Assigned To Triage Finance => dmiguelez
2019-08-08 08:26 hgbot Checkin
2019-08-08 08:26 hgbot Note Added: 0113892
2019-08-08 08:26 hgbot Status feedback => resolved
2019-08-08 08:26 hgbot Resolution open => fixed
2019-08-08 08:26 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/89ffba6ba6bf5d3b7d82b54c889de99a12e54f39 [^]
2019-08-08 08:26 dmiguelez Review Assigned To => dmiguelez
2019-08-08 08:26 dmiguelez Note Added: 0113893
2019-08-08 08:26 dmiguelez Status resolved => closed
2019-08-22 14:45 hudsonbot Checkin
2019-08-22 14:45 hudsonbot Note Added: 0114217


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker