Skip to content

Commit e14abbf

Browse files
authored
BAEL-1818 lamdba instead of loop; isEmpty() instead of == 0 (eugenp#4791)
1 parent 0be7aa0 commit e14abbf

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎core-java/src/main/java/com/baeldung/connectionpool/connectionpools/BasicConnectionPool.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private BasicConnectionPool(String url, String user, String password, List<Conne
3333

3434
@Override
3535
public Connection getConnection() throws SQLException {
36-
if (connectionPool.size() == 0) {
36+
if (connectionPool.isEmpty()) {
3737
if (usedConnections.size() < MAX_POOL_SIZE) {
3838
connectionPool.add(createConnection(url, user, password));
3939
} else {
@@ -76,9 +76,7 @@ public String getPassword() {
7676
}
7777

7878
public void shutdown() throws SQLException {
79-
for (Connection c : usedConnections) {
80-
this.releaseConnection(c);
81-
}
79+
usedConnections.forEach(this::releaseConnection);
8280
for (Connection c : connectionPool) {
8381
c.close();
8482
}

0 commit comments

Comments
 (0)