diff options
author | Dan Timoney <dtimoney@att.com> | 2017-09-13 21:18:25 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-09-13 21:18:25 +0000 |
commit | 39975ca97ae77b06f0aab34396f7bceda7e6e8e3 (patch) | |
tree | 9e1d98beb370b92ed7e64f617f9a536d04ec0ff3 /dblib/provider | |
parent | 5e8195e2b299a87edae0e3cb0f9ad5c38759beb7 (diff) | |
parent | ce8c59f72c30cc7e1f9b657795ad396fe325ba52 (diff) |
Merge "Fix Blocker/Critical sonar issues"
Diffstat (limited to 'dblib/provider')
-rw-r--r-- | dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java | 42 |
1 files changed, 17 insertions, 25 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 ac67c3f9..7a27a20c 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; @@ -41,21 +54,6 @@ import java.util.Set; import java.util.TimerTask; 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 $ @@ -334,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; @@ -430,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()) { @@ -442,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; } |