|
|
|
@ -360,11 +360,7 @@ public abstract class BaseHikariPool implements HikariPoolMBean, IBagStateListen
|
|
|
|
|
protected final boolean addConnection()
|
|
|
|
|
{
|
|
|
|
|
// Speculative increment of totalConnections with expectation of success
|
|
|
|
|
if (totalConnections.incrementAndGet() > configuration.getMaximumPoolSize()) {
|
|
|
|
|
totalConnections.decrementAndGet();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (totalConnections.incrementAndGet() <= configuration.getMaximumPoolSize()) {
|
|
|
|
|
Connection connection = null;
|
|
|
|
|
try {
|
|
|
|
|
connection = (username == null && password == null) ? dataSource.getConnection() : dataSource.getConnection(username, password);
|
|
|
|
@ -389,15 +385,16 @@ public abstract class BaseHikariPool implements HikariPoolMBean, IBagStateListen
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
totalConnections.decrementAndGet(); // We failed, so undo speculative increment of totalConnections
|
|
|
|
|
|
|
|
|
|
lastConnectionFailure.set(e);
|
|
|
|
|
poolUtils.quietlyCloseConnection(connection);
|
|
|
|
|
LOGGER.debug("Connection attempt to database {} failed: {}", configuration.getPoolName(), e.getMessage(), e);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
totalConnections.decrementAndGet(); // We failed or pool is max, so undo speculative increment of totalConnections
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***********************************************************************
|
|
|
|
|
// Abstract methods
|
|
|
|
|
// ***********************************************************************
|
|
|
|
|