Fix connection leak through connection validation code

This commit is contained in:
Christian Beikov 2021-12-22 10:56:17 +01:00
parent 779cbef20c
commit fec4fb7a85
3 changed files with 10 additions and 7 deletions

View File

@ -551,7 +551,7 @@ public PooledConnections build() {
}
}
private static class PoolState {
private static class PoolState implements Runnable {
//Protecting any lifecycle state change:
private final ReadWriteLock statelock = new ReentrantReadWriteLock();
@ -577,7 +577,7 @@ private void startIfNeeded() {
}
executorService = Executors.newSingleThreadScheduledExecutor( new ValidationThreadFactory() );
executorService.scheduleWithFixedDelay(
pool::validate,
this,
validationInterval,
validationInterval,
TimeUnit.SECONDS
@ -589,6 +589,13 @@ private void startIfNeeded() {
}
}
@Override
public void run() {
if ( active ) {
pool.validate();
}
}
public void stop() {
statelock.writeLock().lock();
try {

View File

@ -60,10 +60,7 @@ public Integer toRelationalValue(E domainForm) {
@Override
public int getJdbcTypeCode() {
// note, even though we convert the enum to
// an Integer here, we actually map it to a
// database column of type TINYINT by default
return Types.TINYINT;
return jdbcType.getJdbcTypeCode();
}
@Override

View File

@ -74,7 +74,6 @@ public void stop() {
public void reset() {
super.stop();
config = null;
}
private static class Config {