Skip to content

Commit 0cf8192

Browse files
authored
On close() check if underlying connection is closed (#73)
* On close() check if underlying connection is closed
1 parent 580dfbe commit 0cf8192

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

ebean-datasource/src/main/java/io/ebean/datasource/pool/ConnectionPool.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,10 @@ void returnConnectionForceClose(PooledConnection pooledConnection) {
601601
returnTheConnection(pooledConnection, true);
602602
}
603603

604+
void removeClosedConnection(PooledConnection pooledConnection) {
605+
queue.returnPooledConnection(pooledConnection, true);
606+
}
607+
604608
/**
605609
* Return connection. If forceClose is true then this is a bad connection that
606610
* must be removed and closed fully.

ebean-datasource/src/main/java/io/ebean/datasource/pool/PooledConnection.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ public void close() throws SQLException {
394394
}
395395

396396
try {
397+
if (connection.isClosed()) {
398+
pool.removeClosedConnection(this);
399+
return;
400+
}
397401
// reset the autoCommit back if client code changed it
398402
if (resetAutoCommit) {
399403
connection.setAutoCommit(pool.isAutoCommit());

0 commit comments

Comments
 (0)