@@ -12107,10 +12107,11 @@ public void testBug96900() throws Exception {
1210712107 Supplier<Integer> sessionCount = () -> {
1210812108 try {
1210912109 this.stmt.execute("FLUSH STATUS");
12110+ TimeUnit.SECONDS.sleep(1); // Status values don't update immediately.
1211012111 this.rs = this.stmt.executeQuery("SHOW GLOBAL STATUS LIKE 'threads_connected'");
1211112112 this.rs.next();
1211212113 return this.rs.getInt(2);
12113- } catch (SQLException e) {
12114+ } catch (Exception e) {
1211412115 throw new RuntimeException(e.getMessage(), e);
1211512116 }
1211612117 };
@@ -12126,7 +12127,7 @@ public void testBug96900() throws Exception {
1212612127
1212712128 new Thread(() -> {
1212812129 try {
12129- testStmt.executeQuery("SELECT SLEEP(600 )");
12130+ testStmt.executeQuery("SELECT SLEEP(60 )");
1213012131 } catch (Throwable e) {
1213112132 e.printStackTrace();
1213212133 }
@@ -12137,11 +12138,9 @@ public void testBug96900() throws Exception {
1213712138 assertEquals(1, sessionCount.get() - initialSessionCount);
1213812139
1213912140 testStmt.cancel();
12140- TimeUnit.SECONDS.sleep(1); // Status values don't update immediately.
1214112141 assertEquals(1, sessionCount.get() - initialSessionCount);
1214212142
1214312143 testConn.close();
12144- TimeUnit.SECONDS.sleep(1); // Status values don't update immediately.
1214512144 assertEquals(0, sessionCount.get() - initialSessionCount);
1214612145 }
1214712146
@@ -12157,10 +12156,11 @@ public void testBug99260() throws Exception {
1215712156 Supplier<Integer> sessionCount = () -> {
1215812157 try {
1215912158 this.stmt.execute("FLUSH STATUS");
12159+ TimeUnit.SECONDS.sleep(1); // Status values don't update immediately.
1216012160 this.rs = this.stmt.executeQuery("SHOW GLOBAL STATUS LIKE 'threads_connected'");
1216112161 this.rs.next();
1216212162 return this.rs.getInt(2);
12163- } catch (SQLException e) {
12163+ } catch (Exception e) {
1216412164 throw new RuntimeException(e.getMessage(), e);
1216512165 }
1216612166 };
@@ -12170,20 +12170,17 @@ public void testBug99260() throws Exception {
1217012170 props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
1217112171
1217212172 Connection testConn = getConnectionWithProps(props);
12173-
12174- int initialSessionCount = sessionCount.get();
12175-
1217612173 Statement testStmt = testConn.createStatement();
1217712174 testStmt.setQueryTimeout(1);
12175+ int initialSessionCount = sessionCount.get();
1217812176 for (int i = 0; i < 5; i++) {
1217912177 assertThrows(MySQLTimeoutException.class, "Statement cancelled due to timeout or client request", () -> {
1218012178 testStmt.executeQuery("SELECT SLEEP(30)");
1218112179 return null;
1218212180 });
1218312181 // The difference between the `initialSessionCount` and the current session count would be greater than one if connections external to this test are
1218412182 // created in between. Chances for this to happen in a controlled or development environment are very low and can be neglected.
12185- TimeUnit.SECONDS.sleep(1); // Status values don't update immediately.
12186- assertEquals(0, sessionCount.get() - initialSessionCount);
12183+ assertTrue(sessionCount.get() - initialSessionCount < 1);
1218712184 }
1218812185
1218912186 testConn.close();
0 commit comments