Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0033909Openbravo ERPA. Platformpublic2016-09-06 12:212016-09-26 09:31
gorkaion 
gorkaion 
normalmajoralways
closedfixed 
5
 
pi3.0PR16Q4 
alostale
Core
No
0033909: NPE exception if a commitAndClose() is executed in a onTransactionComplete handler
Consider a EventHandler that fires on the TransactionCompleted event and that performs a commitAndClose() in its code.

If the event handler is fired by another commitAndClose() a NPE is thrown on the second commitAndClose execution.

This is happens as both executions are on the same SessionHandler instance. The first one does "setSession(null)" so when the second one executes the "closeSession()" a NPE is thrown because the "session" object is null.
Update pi to cd08dd7274e3 revision.

1 Go to product characteristics window.
2 Create a new characteristic and a new value.
3 On the new value click on AddProducts and select a couple of products.
4 Press done and the process fails with a NPE.

The reason of the NPE is:

1 DalThreadHandler executes the commitAndClose() when the add product process finishes.
2 this fires the ProductCharacteristicValueEventHandler which executes "importEntryManager.createImportEntry()"
3. the createImportEntry does another commitAndClose() on the same SessionHandler instance whichs sets to null the session
4. the first commitAndClose() continues the execution and when doint the closeSession() the session is already null and fails.
Add a null check in the SessionHandler.closeSession() method:

  protected void closeSession() {
    if (session != null && session.isOpen()) {
      session.close();
    }
  }
No tags attached.
Issue History
2016-09-06 12:21gorkaionNew Issue
2016-09-06 12:21gorkaionAssigned To => gorkaion
2016-09-06 12:21gorkaionModules => Core
2016-09-06 12:21gorkaionTriggers an Emergency Pack => No
2016-09-07 09:52hgbotCheckin
2016-09-07 09:52hgbotNote Added: 0089797
2016-09-07 09:52hgbotStatusnew => resolved
2016-09-07 09:52hgbotResolutionopen => fixed
2016-09-07 09:52hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/e46e66b4f2191ff0a1ca2e4c4ac1818dc2353532 [^]
2016-09-07 19:58hudsonbotCheckin
2016-09-07 19:58hudsonbotNote Added: 0089813
2016-09-15 09:37gorkaionReview Assigned To => alostale
2016-09-26 09:31alostaleStatusresolved => closed
2016-09-26 09:31alostaleFixed in Version => 3.0PR16Q4

Notes
(0089797)
hgbot   
2016-09-07 09:52   
Repository: erp/devel/pi
Changeset: e46e66b4f2191ff0a1ca2e4c4ac1818dc2353532
Author: Gorka Ion Damián <gorkaion.damian <at> openbravo.com>
Date: Tue Sep 06 12:25:45 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/e46e66b4f2191ff0a1ca2e4c4ac1818dc2353532 [^]

Fixes issue 33909. Add null check on closeSession

On some very specific scenarios it is possible to execute 2 commitAndClose or
rollbacks on the same SessionHandler instance. As both methods calls the
setSession(null) and closeSession() methods a NPE is thrown on the second
execution.

---
M src/org/openbravo/dal/core/SessionHandler.java
---
(0089813)
hudsonbot   
2016-09-07 19:58   
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/97008b02fc55 [^]
Maturity status: Test