mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for "timeBetweenEvictionRunsMillis > keepAliveBetweenTimeMillis"
This commit is contained in:
@@ -790,6 +790,10 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
|
||||
LOG.error("keepAliveBetweenTimeMillis should be greater than 30000");
|
||||
}
|
||||
|
||||
if (keepAliveBetweenTimeMillis <= timeBetweenEvictionRunsMillis) {
|
||||
LOG.warn("keepAliveBetweenTimeMillis should be greater than timeBetweenEvictionRunsMillis");
|
||||
}
|
||||
|
||||
this.keepAliveBetweenTimeMillis = keepAliveBetweenTimeMillis;
|
||||
}
|
||||
|
||||
|
||||
@@ -870,6 +870,10 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
throw new SQLException("maxEvictableIdleTimeMillis must be grater than minEvictableIdleTimeMillis");
|
||||
}
|
||||
|
||||
if (keepAlive && keepAliveBetweenTimeMillis <= timeBetweenEvictionRunsMillis) {
|
||||
throw new SQLException("keepAliveBetweenTimeMillis must be grater than timeBetweenEvictionRunsMillis");
|
||||
}
|
||||
|
||||
if (this.driverClass != null) {
|
||||
this.driverClass = driverClass.trim();
|
||||
}
|
||||
@@ -2864,7 +2868,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
for (;;) {
|
||||
// 从前面开始删除
|
||||
try {
|
||||
if (closed) {
|
||||
if (closed || closing) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,9 @@ public class DruidDataSourceC3P0Adapter implements DataSource, DruidDataSourceC3
|
||||
}
|
||||
|
||||
public void setIdleConnectionTestPeriod(int idleConnectionTestPeriod) {
|
||||
dataSource.setTimeBetweenEvictionRunsMillis(((long) idleConnectionTestPeriod) * 1000L);
|
||||
long timeBetweenEvictionRunsMillis = ((long) idleConnectionTestPeriod) * 1000L;
|
||||
dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
|
||||
dataSource.setKeepAliveBetweenTimeMillis(timeBetweenEvictionRunsMillis * 2);
|
||||
}
|
||||
|
||||
public int getInitialPoolSize() {
|
||||
|
||||
@@ -37,9 +37,12 @@ public class KeepAliveTest extends TestCase {
|
||||
public void test_keepAlive() throws Exception {
|
||||
dataSource.init();
|
||||
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
if (dataSource.getMinIdle() == dataSource.getPoolingCount()) {
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
int poolingCount = dataSource.getPoolingCount();
|
||||
if (poolingCount >= dataSource.getMinIdle()) {
|
||||
break;
|
||||
} else {
|
||||
System.out.println("poolingCount : " + poolingCount);
|
||||
}
|
||||
Thread.sleep(10 * 1);
|
||||
}
|
||||
@@ -55,8 +58,5 @@ public class KeepAliveTest extends TestCase {
|
||||
}
|
||||
// assertEquals(dataSource.getMaxActive(), dataSource.getPoolingCount());
|
||||
|
||||
|
||||
|
||||
Thread.sleep(1000 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user