diff options
2 files changed, 23 insertions, 30 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 ac67c3f94..7a27a20ce 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; } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java index 741169c3b..486d0ccc1 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java @@ -21,10 +21,6 @@ package org.onap.ccsdk.sli.core.dblib.factory; -import java.sql.SQLException; -import java.util.Set; -import java.util.concurrent.Callable; - import org.onap.ccsdk.sli.core.dblib.CachedDataSource; import org.onap.ccsdk.sli.core.dblib.CachedDataSourceFactory; import org.onap.ccsdk.sli.core.dblib.DBResourceManager; @@ -34,6 +30,10 @@ import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.sql.SQLException; +import java.util.Set; +import java.util.concurrent.Callable; + /** * @version $Revision: 1.6 $ * Change Log @@ -84,7 +84,8 @@ public abstract class AbstractResourceManagerFactory { } }; if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Completed CachedDataSource.Call and notifyAll from " + ds.getDbConnectionName()); + LOGGER.debug("Completed CachedDataSource.Call and notifyAll from " + (ds != null ? ds + .getDbConnectionName() : null)); } Thread worker = new Thread(closure); worker.setDaemon(true); |