Openbravo Issue Tracking System - Modules
View Issue Details
0041215ModulesAdvanced Paymentspublic2019-07-01 19:182019-08-22 14:45
martinsdan 
dmiguelez 
normalmajoralways
closedfixed 
3018.01
 
 
dmiguelez
0041215: 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.

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/:?]
- 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
The problem is related to the call of lockSequence(seq) in getDocumentNo.
I think the specific problem is OBDal.getInstance().getSession().evict(seq).

No tags attached.
? ProductKeyfromSequenceEventHandler.java (2,516) 2019-07-02 12:51
https://issues.openbravo.com/file_download.php?file_id=13077&type=bug
Issue History
2019-07-01 19:18martinsdanNew Issue
2019-07-01 19:18martinsdanAssigned To => Triage Finance
2019-07-02 12:49santi_lozanoResolution time => 1563832800
2019-07-02 12:51santi_lozanoFile Added: ProductKeyfromSequenceEventHandler.java
2019-07-02 13:02egoitzAssigned ToTriage Finance => platform
2019-07-02 13:03egoitzSeverityminor => major
2019-07-17 11:00martinsdanIssue Monitored: martinsdan
2019-07-25 17:08AugustoMauchNote Added: 0113650
2019-07-25 17:08AugustoMauchStatusnew => feedback
2019-07-25 17:08AugustoMauchAssigned Toplatform => martinsdan
2019-07-25 17:45AugustoMauchAssigned Tomartinsdan => Triage Finance
2019-07-31 12:49dmiguelezNote Added: 0113733
2019-08-06 11:54SandrahuguetAssigned ToTriage Finance => dmiguelez
2019-08-08 08:26hgbotCheckin
2019-08-08 08:26hgbotNote Added: 0113892
2019-08-08 08:26hgbotStatusfeedback => resolved
2019-08-08 08:26hgbotResolutionopen => fixed
2019-08-08 08:26hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/89ffba6ba6bf5d3b7d82b54c889de99a12e54f39 [^]
2019-08-08 08:26dmiguelezReview Assigned To => dmiguelez
2019-08-08 08:26dmiguelezNote Added: 0113893
2019-08-08 08:26dmiguelezStatusresolved => closed
2019-08-22 14:45hudsonbotCheckin
2019-08-22 14:45hudsonbotNote Added: 0114217

Notes
(0113650)
AugustoMauch   
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   
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   
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   
2019-08-08 08:26   
Code Review + Testing Ok
(0114217)
hudsonbot   
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