in old/dekaf-core/src/main/java/org/jetbrains/dekaf/jdbc/pooling/ConnectionPool.java [127:153]
private Connection provideWithConnection() throws SQLException {
try {
// try to get already obtained connection
@Nullable
Connection connection = myFreeConnections.poll(myBorrowTimeBeforeReplenish, TimeUnit.MILLISECONDS);
if (connection != null) return connection;
// check whether we can obtain a new one
while (myAllConnections.size() < myConnectionsLimit) {
obtainOneConnectionIntoPool();
connection = myFreeConnections.poll(myBorrowTimeBeforeReplenish, TimeUnit.MILLISECONDS);
if (connection != null) return connection;
}
// wait for one is released by another thread
connection = myFreeConnections.poll(myBorrowTimeOut, TimeUnit.MILLISECONDS);
if (connection != null) return connection;
// we have no luck :(
int n = myAllConnections.size();
throw new ConnectionPoolExhaustedException("The Connection Pool exhausted: all "+n+" connections are borrowed and not returned yet.");
}
catch (InterruptedException ie) {
throw new ConnectionPoolOperationInterruptedException("Operation interrupted", ie, "<provide with connection>");
}
}