Fix Sonar Issue 09/34109/1
authorBharath Thiruveedula <bharath.thiruveedula@verizon.com>
Mon, 5 Mar 2018 18:40:51 +0000 (00:10 +0530)
committerBharath Thiruveedula <bharath.thiruveedula@verizon.com>
Mon, 5 Mar 2018 18:43:52 +0000 (00:13 +0530)
Rename "jdbi" which hides the field declared at line 68
Link: https://sonar.onap.org/project/issues?id=org.onap.dcaegen2.platform%3Ainventory-api&open=AWEPiFFX-08if2a6xy_T&resolved=false&severities=MAJOR
Change-Id: Iae7765c0d58be81b02977f2a3e9c300a8e4c757b
Issue-ID: DCAEGEN2-380
Signed-off-by: Bharath Thiruveedula <bharath_ves@hotmail.com>
src/main/java/org/onap/dcae/inventory/daos/InventoryDAOManager.java

index 2bd17bf..dbdf546 100644 (file)
@@ -98,11 +98,11 @@ public final class InventoryDAOManager {
      */
     public void initialize() {
         final DBIFactory factory = new DBIFactory();
-        final DBI jdbi = factory.build(this.environment, this.configuration.getDataSourceFactory(), "dcae-database");
-        jdbi.registerArgumentFactory(new StringListArgument());
+        final DBI jdbi_local = factory.build(this.environment, this.configuration.getDataSourceFactory(), "dcae-database");
+        jdbi_local.registerArgumentFactory(new StringListArgument());
 
         for (Class<? extends InventoryDAO> daoClass : DAO_CLASSES) {
-            final InventoryDAO dao = jdbi.onDemand(daoClass);
+            final InventoryDAO dao = jdbi_local.onDemand(daoClass);
 
             if (dao.checkIfTableExists()) {
                 LOG.info(String.format("Sql table exists: %s", daoClass.getSimpleName()));
@@ -114,7 +114,7 @@ public final class InventoryDAOManager {
 
         // CREATE VIEWS
         // TODO: This doesn't belong here and is not consistent with the above approach. Make it better.
-        try (Handle jdbiHandle = jdbi.open()) {
+        try (Handle jdbiHandle = jdbi_local.open()) {
             String viewName = "dcae_service_types_latest";
             String checkQuery = String.format("select exists (select * from information_schema.tables where table_name = '%s')",
                     viewName);
@@ -135,7 +135,7 @@ public final class InventoryDAOManager {
         }
 
         // Do this assignment at the end after performing table checks to ensure that connection is good
-        this.jdbi = jdbi;
+        this.jdbi = jdbi_local;
     }
 
     private InventoryDAO getDAO(Class<? extends InventoryDAO> klass) {