bug fixed for "timeBetweenEvictionRunsMillis > keepAliveBetweenTimeMillis"

This commit is contained in:
高铁
2021-04-19 13:55:13 +08:00
parent 5519fb1aa0
commit 0aab08745e
4 changed files with 17 additions and 7 deletions
@@ -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() {