summaryrefslogtreecommitdiffstats
path: root/dblib/provider
diff options
context:
space:
mode:
authorshashikanth <shashikanth.vh@huawei.com>2017-09-11 18:52:19 +0530
committershashikanth <shashikanth.vh@huawei.com>2017-09-11 18:52:24 +0530
commitce8c59f72c30cc7e1f9b657795ad396fe325ba52 (patch)
tree8756b2d5b378a3c02ea3065d3ed11a0a5672e3a3 /dblib/provider
parent03332a17a549438d204d8f0068a995a7c8708ed3 (diff)
Fix Blocker/Critical sonar issues
Fix Blocker/Critical sonar issues in ccsdk/core module https://sonar.onap.org/component_issues?id=org.openecomp.sdnc.core%3Asdnc-core#resolved=false|severities=BLOCKER Issue-Id: CCSDK-67 Change-Id: Iec86b90f7085f4b96d4f92adf4064b70640fcf22 Signed-off-by: shashikanth.vh <shashikanth.vh@huawei.com>
Diffstat (limited to 'dblib/provider')
-rw-r--r--dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java44
1 files changed, 17 insertions, 27 deletions
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java
index 46c003a5..7ed54306 100644
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java
@@ -20,6 +20,19 @@
package org.onap.ccsdk.sli.core.dblib;
+import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException;
+import org.apache.tomcat.jdbc.pool.PoolExhaustedException;
+import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool;
+import org.onap.ccsdk.sli.core.dblib.factory.AbstractDBResourceManagerFactory;
+import org.onap.ccsdk.sli.core.dblib.factory.AbstractResourceManagerFactory;
+import org.onap.ccsdk.sli.core.dblib.factory.DBConfigFactory;
+import org.onap.ccsdk.sli.core.dblib.pm.PollingWorker;
+import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.sql.DataSource;
+import javax.sql.rowset.CachedRowSet;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLDataException;
@@ -38,26 +51,9 @@ import java.util.PriorityQueue;
import java.util.Properties;
import java.util.Queue;
import java.util.Set;
-import java.util.Timer;
import java.util.TimerTask;
-import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;
-import javax.sql.DataSource;
-import javax.sql.rowset.CachedRowSet;
-
-import org.apache.tomcat.jdbc.pool.PoolExhaustedException;
-import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool;
-import org.onap.ccsdk.sli.core.dblib.factory.AbstractDBResourceManagerFactory;
-import org.onap.ccsdk.sli.core.dblib.factory.AbstractResourceManagerFactory;
-import org.onap.ccsdk.sli.core.dblib.factory.DBConfigFactory;
-import org.onap.ccsdk.sli.core.dblib.pm.PollingWorker;
-import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor;
-
-import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* @version $Revision: 1.15 $
@@ -336,11 +332,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb
}
sources.remove(active);
return active.getData(statement, arguments);
- } catch(SQLDataException exc){
- throw exc;
- } catch(SQLSyntaxErrorException exc){
- throw exc;
- } catch(SQLIntegrityConstraintViolationException exc){
+ } catch(SQLDataException | SQLSyntaxErrorException | SQLIntegrityConstraintViolationException exc){
throw exc;
} catch(Throwable exc){
lastException = exc;
@@ -432,7 +424,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb
}
CachedDataSource findMaster() throws PoolExhaustedException, MySQLNonTransientConnectionException {
- CachedDataSource master = null;
+ CachedDataSource master;
CachedDataSource[] dss = this.dsQueue.toArray(new CachedDataSource[0]);
for(int i=0; i<dss.length; i++) {
if(!dss[i].isSlave()) {
@@ -444,10 +436,8 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb
return master;
}
}
- if(master == null) {
- LOGGER.warn("MASTER not found.");
- }
- return master;
+ LOGGER.warn("MASTER not found.");
+ return null;
}