From 0d16f10774cdc7bc96bfea7f007c7823e650795d Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Tue, 01 Sep 2026 13:47:43 +0000
Subject: [PATCH] [#879] Skip the validation of a pooled JDBC connection returned a moment ago (#883)

---
 opendj-server-legacy/src/test/java/org/opends/server/backends/jdbc/StampConnectionTestCase.java |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/jdbc/StampConnectionTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/jdbc/StampConnectionTestCase.java
index 05b055e..25c5c14 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/jdbc/StampConnectionTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/jdbc/StampConnectionTestCase.java
@@ -214,12 +214,13 @@
 
 	/**
 	 * A driver reports the vendor error of a failed statement as the next exception of a generic
-	 * one at least as often as it reports it as the cause. Reading only the cause chain classifies
-	 * a lock timeout as a rejection, which leaves the tree unstamped until the next start over a
-	 * moment of contention.
+	 * one at least as often as it reports it as the cause, and the statement of a try-with-resources
+	 * carries what its {@code close()} saw as a suppressed exception. Reading fewer chains than the
+	 * classifiers of a write read classifies a lock timeout - or a connection that broke - as a
+	 * rejection, which leaves the tree unstamped for the life of the backend.
 	 */
 	@Test
-	public void testFailureScopeWalksBothChains() {
+	public void testFailureScopeWalksEveryChain() {
 		final SQLException reportedAsTheCause = new SQLException("statement failed",
 			new SQLException("lock wait timeout exceeded", "HY000", 1205));
 		assertEquals(JDBCStorage.failureScope(reportedAsTheCause, JDBCStorage.Dialect.MYSQL),
@@ -236,6 +237,13 @@
 		assertEquals(JDBCStorage.failureScope(connectionGone, JDBCStorage.Dialect.MYSQL),
 			JDBCStorage.FailureScope.SESSION, "a connection exception on the next-exception chain was missed");
 
+		// the close() of the statement is where a connection that broke under a stamp is often the
+		// only witness, and it joins the failure being unwound as a suppressed exception (JLS 14.20.3.1)
+		final SQLException reportedByTheClose = new SQLException("statement failed");
+		reportedByTheClose.addSuppressed(new SQLException("connection closed", "08006"));
+		assertEquals(JDBCStorage.failureScope(reportedByTheClose, JDBCStorage.Dialect.MYSQL),
+			JDBCStorage.FailureScope.SESSION, "a connection exception suppressed into the failure was missed");
+
 		// a driver that chains an exception back to itself must not make the walk loop
 		final SQLException selfReferring = new SQLException("statement failed");
 		selfReferring.setNextException(selfReferring);

--
Gitblit v1.10.0