in src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java [162:188]
protected final void closeInternal() throws SQLException {
try {
passivate();
} finally {
if (connection != null) {
boolean connectionIsClosed;
try {
connectionIsClosed = connection.isClosed();
} catch (final SQLException e) {
// not sure what the state is, so assume the connection is open.
connectionIsClosed = false;
}
try {
// DBCP-512: Avoid exceptions when closing a connection in multi-threaded use case.
// Avoid closing again, which should be a no-op, but some drivers like H2 throw an exception when
// closing from multiple threads.
if (!connectionIsClosed) {
connection.close();
}
} finally {
closed = true;
}
} else {
closed = true;
}
}
}