BAEL-1818 lamdba instead of loop; isEmpty() instead of == 0 (#4791)

This commit is contained in:
Predrag Maric 2018-07-23 07:41:59 +02:00 committed by GitHub
parent 0be7aa087f
commit e14abbfb58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -33,7 +33,7 @@ public class BasicConnectionPool implements ConnectionPool {
@Override @Override
public Connection getConnection() throws SQLException { public Connection getConnection() throws SQLException {
if (connectionPool.size() == 0) { if (connectionPool.isEmpty()) {
if (usedConnections.size() < MAX_POOL_SIZE) { if (usedConnections.size() < MAX_POOL_SIZE) {
connectionPool.add(createConnection(url, user, password)); connectionPool.add(createConnection(url, user, password));
} else { } else {
@ -76,9 +76,7 @@ public class BasicConnectionPool implements ConnectionPool {
} }
public void shutdown() throws SQLException { public void shutdown() throws SQLException {
for (Connection c : usedConnections) { usedConnections.forEach(this::releaseConnection);
this.releaseConnection(c);
}
for (Connection c : connectionPool) { for (Connection c : connectionPool) {
c.close(); c.close();
} }