Openbravo Issue Tracking System - Openbravo ERP |
View Issue Details |
|
ID | Project | Category | View Status | Date Submitted | Last Update |
0028119 | Openbravo ERP | A. Platform | public | 2014-11-07 09:51 | 2014-12-30 23:24 |
|
Reporter | alostale | |
Assigned To | AugustoMauch | |
Priority | normal | Severity | minor | Reproducibility | unable to reproduce |
Status | closed | Resolution | fixed | |
Platform | | OS | 5 | OS Version | |
Product Version | | |
Target Version | | Fixed in Version | 3.0PR15Q1 | |
Merge Request Status | |
Review Assigned To | alostale |
OBNetwork customer | |
Web browser | |
Modules | Core |
Support ticket | |
Regression level | |
Regression date | |
Regression introduced in release | |
Regression introduced by commit | |
Triggers an Emergency Pack | No |
|
Summary | 0028119: potential NPE in DataSourceServiceProvider |
Description | There is a compilation warning in DataSourceServiceProvider:
Null pointer access: The variable ds can only be null at this location
problematic code is around line 84:
if (ApplicationConstants.DATASOURCEBASEDTABLE.equals(table.getDataOriginType())) {
dataSource = table.getObserdsDatasource();
ds.setEntity(ModelProvider.getInstance().getEntityByTableId(table.getId()));
}
This code was added by changest
changeset: 20346:faaff1ca4c4a
user: Augusto Mauch <augusto.mauch@openbravo.com>
date: Mon May 06 09:42:42 2013 +0200
summary: [DS Based Tables] Set the entity of the datasource
diff -r 8113618afb03 -r faaff1ca4c4a modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServiceProvider.java
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServiceProvider.java Mon May 06 09:41:54 2013 +0200
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServiceProvider.java Mon May 06 09:42:42 2013 +0200
@@ -81,6 +81,7 @@
Table table = (Table) qTable.list().get(0);
if (ApplicationConstants.DATASOURCEBASEDTABLE.equals(table.getDataOriginType())) {
dataSource = table.getObserdsDatasource();
+ ds.setEntity(ModelProvider.getInstance().getEntityByTableId(table.getId()));
}
}
if (dataSource == null) {
|
Steps To Reproduce | - |
Proposed Solution | Check the flow, if it make sense fix it, if not remove |
Additional Information | |
Tags | No tags attached. |
Relationships | related to | feature request | 0025996 | 3.0PR14Q3 | closed | AugustoMauch | HQL based tables | related to | defect | 0028117 | 3.0PR15Q1 | closed | alostale | MultipleDeleteActionHandler throws an exception when removing several rows of a datasource based window |
|
Attached Files | |
|
Issue History |
Date Modified | Username | Field | Change |
2014-11-07 09:51 | alostale | New Issue | |
2014-11-07 09:51 | alostale | Assigned To | => AugustoMauch |
2014-11-07 09:51 | alostale | Modules | => Core |
2014-11-07 09:51 | alostale | Triggers an Emergency Pack | => No |
2014-11-07 09:52 | alostale | Description Updated | bug_revision_view_page.php?rev_id=6983#r6983 |
2014-11-07 09:55 | alostale | Relationship added | related to 0025996 |
2014-11-07 10:02 | alostale | Relationship added | related to 0028117 |
2014-11-17 18:07 | AugustoMauch | Issue Monitored: alostale | |
2014-11-17 18:07 | AugustoMauch | Review Assigned To | => alostale |
2014-11-17 18:08 | hgbot | Checkin | |
2014-11-17 18:08 | hgbot | Note Added: 0071722 | |
2014-11-17 18:08 | hgbot | Checkin | |
2014-11-17 18:08 | hgbot | Note Added: 0071723 | |
2014-11-17 18:08 | hgbot | Checkin | |
2014-11-17 18:08 | hgbot | Note Added: 0071724 | |
2014-11-17 18:09 | hgbot | Checkin | |
2014-11-17 18:09 | hgbot | Note Added: 0071725 | |
2014-11-17 18:09 | hgbot | Status | new => resolved |
2014-11-17 18:09 | hgbot | Resolution | open => fixed |
2014-11-17 18:09 | hgbot | Fixed in SCM revision | => http://code.openbravo.com/erp/devel/pi/rev/c77d6ec09d26a627f700bcd140454ad26052e7ca [^] |
2014-11-17 18:09 | hgbot | Checkin | |
2014-11-17 18:09 | hgbot | Note Added: 0071726 | |
2014-11-17 18:17 | AugustoMauch | Note Added: 0071727 | |
2014-11-17 18:18 | AugustoMauch | Note Added: 0071728 | |
2014-11-24 13:44 | alostale | Note Added: 0071937 | |
2014-11-24 13:44 | alostale | Status | resolved => closed |
2014-11-24 13:44 | alostale | Fixed in Version | => 3.0PR15Q1 |
2014-12-30 23:24 | hudsonbot | Checkin | |
2014-12-30 23:24 | hudsonbot | Note Added: 0073063 | |
2014-12-30 23:24 | hudsonbot | Checkin | |
2014-12-30 23:24 | hudsonbot | Note Added: 0073064 | |
2014-12-30 23:24 | hudsonbot | Checkin | |
2014-12-30 23:24 | hudsonbot | Note Added: 0073065 | |
2014-12-30 23:24 | hudsonbot | Checkin | |
2014-12-30 23:24 | hudsonbot | Note Added: 0073066 | |
2014-12-30 23:24 | hudsonbot | Checkin | |
2014-12-30 23:24 | hudsonbot | Note Added: 0073067 | |
Notes |
|
(0071722)
|
hgbot
|
2014-11-17 18:08
|
|
Repository: erp/devel/pi
Changeset: 2403611658277729f62f7fb351b2e0cf0cdba231
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Fri Nov 07 13:17:56 2014 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/2403611658277729f62f7fb351b2e0cf0cdba231 [^]
Related with issue 28119: DataSourceServiceProvider.getDataSource refactor #1
The DataSourceServiceProvider.getDataSource method is going to be refactored before fixing 28119, because its logic is very messy.
In this first part of the refactor the obtention of the DataSource and the obtention of the DataSourceService is going the be separated. The first part of the method now is in charge os retrieving the DataSource, and the second part obtains the DataSourceService associated with the DataSource.
---
M modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServiceProvider.java
---
|
|
|
(0071723)
|
hgbot
|
2014-11-17 18:08
|
|
Repository: erp/devel/pi
Changeset: d36de12150b1e1da1594f6fc5f8c8b4337492e7c
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Fri Nov 07 14:00:05 2014 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/d36de12150b1e1da1594f6fc5f8c8b4337492e7c [^]
Related with issue 28119: Refactor #2 and part of actual fix
Two methods have been extracted: getRealDataSource and getDataSourceServiceFromDataSource. In the previous changeset the retrieval of the DataSource and DataSource service was separated, now each code is in its respective method. I would have liked to name the first method getDataSource, but that name was already taken by the public method that returns a DataSourceServe.
This changeset also contains the first part of the fix. The original problem was that the entity of the DataSourceService was being set before the DataSourceService was initialized. This used to be done in the part that retrieved the DataSource, now it has been removed. The entity will be set to the DataSourceService in the next changeset.
---
M modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServiceProvider.java
---
|
|
|
(0071724)
|
hgbot
|
2014-11-17 18:08
|
|
Repository: erp/devel/pi
Changeset: ac61bb2afe11c922862986a4ae472f19a60a2db0
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Fri Nov 07 15:05:43 2014 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/ac61bb2afe11c922862986a4ae472f19a60a2db0 [^]
Related with issue 28119: Do not fail is trying to retrieve a null entity
The ModelProvider.getEntity method, which is used to retrieve an entity based on its table name, used to fail if an entity with the provided table name did not exist. This was not done when retrieving an entity given its table id or its table table_name.
Now it is possible to call to the getEntity method with an invalid table name without failing if the entity does not exist. For this a new getEntity method has been overriden with a checkIfNotExists boolean parameter. The original signature has been preserved, and will call the new one with checkIfNotExists=true, to ensure that the default behaviour is the same as it used to be.
---
M src/org/openbravo/base/model/ModelProvider.java
---
|
|
|
(0071725)
|
hgbot
|
2014-11-17 18:09
|
|
Repository: erp/devel/pi
Changeset: c77d6ec09d26a627f700bcd140454ad26052e7ca
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Fri Nov 07 15:09:23 2014 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/c77d6ec09d26a627f700bcd140454ad26052e7ca [^]
Fixes issue 28119: Prevents potential NPE in DataSourceServiceProvider
The original problem was that is potentially possible to set call the setEntity method of a null DataSourceService. Now it is not possible, because that method will only be invoked after the DataSourceService has been properly initialized.
---
M modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServiceProvider.java
---
|
|
|
(0071726)
|
hgbot
|
2014-11-17 18:09
|
|
Repository: erp/devel/pi
Changeset: 305f5c29bb31609710dd2d0f8951c87028b35ebc
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Sun Nov 09 23:42:50 2014 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/305f5c29bb31609710dd2d0f8951c87028b35ebc [^]
Related with issue 28119: Further refactoring
The code that retrieved a datasource from the datasource id, datasource name and table name has been moved to the methods getDataSourceFromDataSourceId, getDataSourceFromDataSourceName and getDataSourceFromTableName respectively.
---
M modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServiceProvider.java
---
|
|
|
|
Tested in Try with success |
|
|
|
The code has been refactored. After refactoring the code, it was clear that the actual fix consisted in setting the entity to the DataSourceService only if one was available. |
|
|
|
code reviewed
tested acquiring DS with the different ways:
-By its ID
-By its Name
-By table name |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|