Author: psteitz Date: Sat Apr 17 02:32:12 2021 New Revision: 1888838 URL: http://svn.apache.org/viewvc?rev=1888838&view=rev Log: Eliminated multiple returns.
Modified: commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java Modified: commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java URL: http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java?rev=1888838&r1=1888837&r2=1888838&view=diff ============================================================================== --- commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java (original) +++ commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java Sat Apr 17 02:32:12 2021 @@ -166,10 +166,7 @@ public class DBCPSoak } dataSource = bds; checkDatabase(); - return; - } - - if (dataSourceType.equals("tomcat-jdbc-pool")) { + } else if (dataSourceType.equals("tomcat-jdbc-pool")) { PoolProperties config = new PoolProperties(); config.setDefaultAutoCommit(autocommit); config.setPassword(connectPassword); @@ -189,54 +186,54 @@ public class DBCPSoak config.setTimeBetweenEvictionRunsMillis((int) timeBetweenEvictions); dataSource = new org.apache.tomcat.jdbc.pool.DataSource(config); checkDatabase(); - return; - } + } else { // PoolingDataSource + Class.forName(driverClass); - Class.forName(driverClass); - - // Create raw connection factory - ConnectionFactory connectionFactory = null; - if (driverType.equals("DriverManager")) { - connectionFactory = new DriverManagerConnectionFactory(connectUrl, - connectUser, - connectPassword); - } else if (driverType.equals("Driver")) { - Properties props = new Properties(); - props.put("user", connectUser); - props.put("password", connectPassword); - connectionFactory = new DriverConnectionFactory((Driver) Class - .forName(driverClass).newInstance(), connectUrl, props); - } else { - throw new ConfigurationException("Bad config setting for driver type"); - } + // Create raw connection factory + ConnectionFactory connectionFactory = null; + if (driverType.equals("DriverManager")) { + connectionFactory = new DriverManagerConnectionFactory(connectUrl, + connectUser, + connectPassword); + } else if (driverType.equals("Driver")) { + Properties props = new Properties(); + props.put("user", connectUser); + props.put("password", connectPassword); + connectionFactory = new DriverConnectionFactory((Driver) Class + .forName(driverClass).newInstance(), connectUrl, props); + } else { + throw new ConfigurationException("Bad config setting for driver type"); + } - PoolableConnectionFactory poolableConnectionFactory = null; - if (factoryType.equals("PoolableConnectionFactory")) { - poolableConnectionFactory = createPoolableConnectionFactory(connectionFactory); - } else if (factoryType.equals("CPDSConnectionFactory")) { - throw new ConfigurationException("CPDSConnectionFactory not implemented yet"); - } else { - throw new ConfigurationException("Invalid factory type: " + - factoryType); - } + PoolableConnectionFactory poolableConnectionFactory = null; + if (factoryType.equals("PoolableConnectionFactory")) { + poolableConnectionFactory = createPoolableConnectionFactory(connectionFactory); + } else if (factoryType.equals("CPDSConnectionFactory")) { + throw new ConfigurationException("CPDSConnectionFactory not implemented yet"); + } else { + throw new ConfigurationException("Invalid factory type: " + + factoryType); + } - // Create object pool - connectionPool = new GenericObjectPool<PoolableConnection>(poolableConnectionFactory); - connectionPool.setMaxTotal(maxActive); - connectionPool.setMaxWaitMillis(maxWait); - connectionPool.setMaxIdle(maxIdle); - connectionPool.setMinIdle(minIdle); - connectionPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictions); - connectionPool.setNumTestsPerEvictionRun(testsPerEviction); - connectionPool.setMinEvictableIdleTimeMillis(idleTimeout); - connectionPool.setTestWhileIdle(testWhileIdle); - connectionPool.setTestOnBorrow(testOnBorrow); - connectionPool.setBlockWhenExhausted(autocommit); - connectionPool.setTestOnReturn(testOnReturn); + // Create object pool + connectionPool = new GenericObjectPool<PoolableConnection>(poolableConnectionFactory); + connectionPool.setMaxTotal(maxActive); + connectionPool.setMaxWaitMillis(maxWait); + connectionPool.setMaxIdle(maxIdle); + connectionPool.setMinIdle(minIdle); + connectionPool + .setTimeBetweenEvictionRunsMillis(timeBetweenEvictions); + connectionPool.setNumTestsPerEvictionRun(testsPerEviction); + connectionPool.setMinEvictableIdleTimeMillis(idleTimeout); + connectionPool.setTestWhileIdle(testWhileIdle); + connectionPool.setTestOnBorrow(testOnBorrow); + connectionPool.setBlockWhenExhausted(autocommit); + connectionPool.setTestOnReturn(testOnReturn); - // Create DataSource - dataSource = new PoolingDataSource<PoolableConnection>(connectionPool); - checkDatabase(); + // Create DataSource + dataSource = new PoolingDataSource<PoolableConnection>(connectionPool); + checkDatabase(); + } } protected void checkDatabase()