This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbutils.git


The following commit(s) were added to refs/heads/master by this push:
     new 987860a  Use try-with-resources
987860a is described below

commit 987860aff286133b97096bb892b5bd0bc944f8dd
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Mon Jul 31 14:38:58 2023 -0400

    Use try-with-resources
---
 src/main/java/org/apache/commons/dbutils/QueryRunner.java | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/dbutils/QueryRunner.java 
b/src/main/java/org/apache/commons/dbutils/QueryRunner.java
index b4d7249..4ff9afc 100644
--- a/src/main/java/org/apache/commons/dbutils/QueryRunner.java
+++ b/src/main/java/org/apache/commons/dbutils/QueryRunner.java
@@ -271,15 +271,12 @@ public class QueryRunner extends AbstractQueryRunner {
             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);

Reply via email to