mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-03-01 15:29:11 +00:00
Fix connection leak through connection validation code
This commit is contained in:
parent
779cbef20c
commit
fec4fb7a85
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -74,7 +74,6 @@ public void stop() {
|
||||
|
||||
public void reset() {
|
||||
super.stop();
|
||||
config = null;
|
||||
}
|
||||
|
||||
private static class Config {
|
||||
|
Loading…
x
Reference in New Issue
Block a user