Skip to content

Commit

Permalink
Fix connection leak through connection validation code
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Dec 22, 2021
1 parent 779cbef commit fec4fb7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Expand Up @@ -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();
Expand All @@ -577,7 +577,7 @@ private void startIfNeeded() {
}
executorService = Executors.newSingleThreadScheduledExecutor( new ValidationThreadFactory() );
executorService.scheduleWithFixedDelay(
pool::validate,
this,
validationInterval,
validationInterval,
TimeUnit.SECONDS
Expand All @@ -589,6 +589,13 @@ private void startIfNeeded() {
}
}

@Override
public void run() {
if ( active ) {
pool.validate();
}
}

public void stop() {
statelock.writeLock().lock();
try {
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -74,7 +74,6 @@ public void stop() {

public void reset() {
super.stop();
config = null;
}

private static class Config {
Expand Down

0 comments on commit fec4fb7

Please sign in to comment.