This is an automated email from the ASF dual-hosted git repository. garydgregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git
commit 68d830cde4299f696e0531144a2a304f383c9dac Author: Gary Gregory <[email protected]> AuthorDate: Sun Nov 22 09:04:19 2026 -0500 Revert "[DBCP-522] Invalidate auto-commit cache before driver calls" This reverts commit b524b7f001f37bc21e3204a7f616f62f0b125883. --- .../apache/commons/dbcp2/DelegatingConnection.java | 1 - .../commons/dbcp2/TestDelegatingConnection.java | 106 --------------------- 2 files changed, 107 deletions(-) diff --git a/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java b/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java index 2567f3f1..5aee5ace 100644 --- a/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java +++ b/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java @@ -856,7 +856,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace i @Override public void setAutoCommit(final boolean autoCommit) throws SQLException { checkOpen(); - cachedAutoCommit = null; try { connection.setAutoCommit(autoCommit); if (cacheState) { diff --git a/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java b/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java index 3c491d3b..c2eea4ee 100644 --- a/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java +++ b/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java @@ -374,112 +374,6 @@ public class TestDelegatingConnection { } } - @Test - void testSetAutoCommitErrorAfterPhysicalChange() throws SQLException { - try (Connection physical = DriverManager.getConnection("jdbc:h2:mem:dcp522_autocommit_error")) { - physical.setAutoCommit(true); - final AssertionError failure = new AssertionError("setAutoCommit failed"); - final Connection faulty = new DelegatingConnection<Connection>(physical) { - @Override - public void setAutoCommit(final boolean autoCommit) throws SQLException { - super.setAutoCommit(autoCommit); - throw failure; - } - }; - try (DelegatingConnection<Connection> outer = new DelegatingConnection<>(faulty)) { - assertTrue(outer.getAutoCommit()); - final AssertionError thrown = assertThrows(AssertionError.class, () -> outer.setAutoCommit(false)); - assertSame(failure, thrown); - assertFalse(physical.getAutoCommit()); - assertFalse(outer.getAutoCommit()); - } - } - } - - @Test - void testSetAutoCommitErrorFromDelegateGetter() throws SQLException { - try (Connection physical = DriverManager.getConnection("jdbc:h2:mem:dcp522_autocommit_getter_error")) { - physical.setAutoCommit(true); - final AssertionError failure = new AssertionError("getAutoCommit failed"); - final Connection faulty = new DelegatingConnection<Connection>(physical) { - private boolean failedOnce; - - @Override - public boolean getAutoCommit() throws SQLException { - if (!failedOnce && !physical.getAutoCommit()) { - failedOnce = true; - throw failure; - } - return physical.getAutoCommit(); - } - }; - try (DelegatingConnection<Connection> outer = new DelegatingConnection<>(faulty)) { - assertTrue(outer.getAutoCommit()); - final AssertionError thrown = assertThrows(AssertionError.class, () -> outer.setAutoCommit(false)); - assertSame(failure, thrown); - assertFalse(physical.getAutoCommit()); - assertFalse(outer.getAutoCommit()); - } - } - } - - @Test - void testSetAutoCommitErrorWithCacheStateDisabled() throws SQLException { - try (Connection physical = DriverManager.getConnection("jdbc:h2:mem:dcp522_autocommit_no_cache")) { - physical.setAutoCommit(true); - final AssertionError failure = new AssertionError("setAutoCommit failed"); - final DelegatingConnection<Connection> faulty = new DelegatingConnection<Connection>(physical) { - @Override - public void setAutoCommit(final boolean autoCommit) throws SQLException { - super.setAutoCommit(autoCommit); - throw failure; - } - }; - faulty.setCacheState(false); - try (DelegatingConnection<DelegatingConnection<Connection>> outer = new DelegatingConnection<>(faulty)) { - outer.setCacheState(false); - assertTrue(outer.getAutoCommit()); - final AssertionError thrown = assertThrows(AssertionError.class, () -> outer.setAutoCommit(false)); - assertSame(failure, thrown); - assertFalse(physical.getAutoCommit()); - assertFalse(outer.getAutoCommit()); - } - } - } - - @Test - void testSetAutoCommitSqlExceptionAfterPhysicalChange() throws SQLException { - try (Connection physical = DriverManager.getConnection("jdbc:h2:mem:dcp522_autocommit_sql_exception")) { - physical.setAutoCommit(true); - final SQLException failure = new SQLException("setAutoCommit failed"); - final Connection faulty = new DelegatingConnection<Connection>(physical) { - @Override - public void setAutoCommit(final boolean autoCommit) throws SQLException { - super.setAutoCommit(autoCommit); - throw failure; - } - }; - try (DelegatingConnection<Connection> outer = new DelegatingConnection<>(faulty)) { - assertTrue(outer.getAutoCommit()); - final SQLException thrown = assertThrows(SQLException.class, () -> outer.setAutoCommit(false)); - assertSame(failure, thrown); - assertFalse(physical.getAutoCommit()); - assertFalse(outer.getAutoCommit()); - } - } - } - - @Test - void testSetAutoCommitSuccessUpdatesCache() throws SQLException { - try (Connection physical = DriverManager.getConnection("jdbc:h2:mem:dcp522_autocommit_success"); - DelegatingConnection<Connection> outer = new DelegatingConnection<>(physical)) { - assertTrue(outer.getAutoCommit()); - outer.setAutoCommit(false); - assertFalse(physical.getAutoCommit()); - assertFalse(outer.getAutoCommit()); - } - } - @Test void testSetClientInfo() throws Exception { // TODO
