Skip to content

Commit

Permalink
Use try-with-resources
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Jul 31, 2023
1 parent 4a2eaf8 commit 987860a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/main/java/org/apache/commons/dbutils/QueryRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,12 @@ private <T> List<T> execute(final Connection conn, final boolean closeConn, fina
boolean moreResultSets = stmt.execute();
// Handle multiple result sets by passing them through the handler
// retaining the final result
ResultSet rs = null;
while (moreResultSets) {
try {
rs = this.wrap(stmt.getResultSet());
try (@SuppressWarnings("resource")
// assume the ResultSet wrapper properly closes
ResultSet rs = this.wrap(stmt.getResultSet())) {
results.add(rsh.handle(rs));
moreResultSets = stmt.getMoreResults();

} finally {
close(rs);
}
}
this.retrieveOutParameters(stmt, params);
Expand Down

0 comments on commit 987860a

Please sign in to comment.