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