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-dbcp.git
The following commit(s) were added to refs/heads/master by this push: new f334c40 Use try-with-resources. f334c40 is described below commit f334c400e4fdfb840d2992fa68c65df2649c1442 Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Fri Jul 9 09:21:14 2021 -0400 Use try-with-resources. --- .../dbcp2/managed/TestManagedConnectionCachedState.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnectionCachedState.java b/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnectionCachedState.java index cf7c442..a67385d 100644 --- a/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnectionCachedState.java +++ b/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnectionCachedState.java @@ -103,13 +103,12 @@ public class TestManagedConnectionCachedState { // begin a transaction transactionManager.begin(); // acquire a connection enlisted in the transaction - final Connection conn = getConnection(); - // check the autocommit status to trigger internal caching - conn.getAutoCommit(); - // ask the transaction manager to rollback - transactionManager.rollback(); - // close the connection - conn.close(); + try (final Connection conn = getConnection()) { + // check the autocommit status to trigger internal caching + conn.getAutoCommit(); + // ask the transaction manager to rollback + transactionManager.rollback(); + } // check that no exceptions about failed rollback during close were logged assertEquals(0, swallowedExceptionRecorder.getExceptions().size()); }