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

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0028119
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] A. Platformminorunable to reproduce2014-11-07 09:512014-12-30 23:24
ReporteralostaleView Statuspublic 
Assigned ToAugustoMauch 
PrioritynormalResolutionfixedFixed in Version3.0PR15Q1
StatusclosedFix in branchFixed in SCM revisionc77d6ec09d26
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Toalostale
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0028119: potential NPE in DataSourceServiceProvider

DescriptionThere 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 SolutionCheck the flow, if it make sense fix it, if not remove
TagsNo tags attached.
Attached Files

- Relationships Relation Graph ] Dependency Graph ]
related to feature request 00259963.0PR14Q3 closedAugustoMauch HQL based tables 
related to defect 00281173.0PR15Q1 closedalostale MultipleDeleteActionHandler throws an exception when removing several rows of a datasource based window 

-  Notes
(0071722)
hgbot (developer)
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 (developer)
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 (developer)
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 (developer)
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 (developer)
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
---
(0071727)
AugustoMauch (developer)
2014-11-17 18:17

Tested in Try with success
(0071728)
AugustoMauch (developer)
2014-11-17 18:18

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.
(0071937)
alostale (developer)
2014-11-24 13:44

code reviewed

tested acquiring DS with the different ways:
-By its ID
-By its Name
-By table name
(0073063)
hudsonbot (developer)
2014-12-30 23:24

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/6525fe229e06 [^]
Maturity status: Test
(0073064)
hudsonbot (developer)
2014-12-30 23:24

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/6525fe229e06 [^]
Maturity status: Test
(0073065)
hudsonbot (developer)
2014-12-30 23:24

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/6525fe229e06 [^]
Maturity status: Test
(0073066)
hudsonbot (developer)
2014-12-30 23:24

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/6525fe229e06 [^]
Maturity status: Test
(0073067)
hudsonbot (developer)
2014-12-30 23:24

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

- 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 View Revisions
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


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker