This is an automated email from the ASF dual-hosted git repository. sunlan pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push: new 38f0cbe309 Trivial refactoring: simplify code with try-with-resources 38f0cbe309 is described below commit 38f0cbe309577faad20f85536f1e47ae1c005fd8 Author: Daniel Sun <sun...@apache.org> AuthorDate: Sat Nov 18 19:29:55 2023 +0800 Trivial refactoring: simplify code with try-with-resources --- subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java index 3ff10ec672..e3d1428cd0 100644 --- a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java +++ b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java @@ -29,7 +29,6 @@ import groovy.transform.stc.SimpleType; import org.codehaus.groovy.runtime.InvokerHelper; import javax.sql.DataSource; - import java.security.PrivilegedExceptionAction; import java.sql.CallableStatement; import java.sql.Connection; @@ -4041,7 +4040,7 @@ public class Sql implements AutoCloseable { @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure) throws SQLException { List<GroovyRowResult> results = new ArrayList<GroovyRowResult>(); - try { + try (rs) { if (metaClosure != null) { metaClosure.call(rs.getMetaData()); } @@ -4057,8 +4056,6 @@ public class Sql implements AutoCloseable { } catch (SQLException e) { LOG.warning("Failed to retrieve row from ResultSet for: " + sql + " because: " + e.getMessage()); throw e; - } finally { - rs.close(); } }