Skip to content

Commit c185ad9

Browse files
committed
fixed test to wait task completeness
1 parent 16520a7 commit c185ad9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

jdbc-v2/src/test/java/com/clickhouse/jdbc/ConnectionTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public void abortTest() throws SQLException {
398398
}
399399

400400
@Test(groups = {"integration"})
401-
public void testNetworkTimeout() throws SQLException {
401+
public void testNetworkTimeout() throws Exception {
402402
try (Connection conn = this.getJdbcConnection()) {
403403
Assert.assertThrows(SQLException.class, () -> conn.setNetworkTimeout(null, 1000));
404404
Assert.assertThrows(SQLException.class, () -> conn.setNetworkTimeout(Executors.newSingleThreadExecutor(), -1));
@@ -408,13 +408,15 @@ public void testNetworkTimeout() throws SQLException {
408408
conn.setNetworkTimeout(executorService, timeout);
409409
Assert.assertEquals(conn.getNetworkTimeout(), timeout);
410410
Statement stmt = conn.createStatement();
411-
try {
412-
ResultSet rs = stmt.executeQuery("SELECT sleepEachRow(1) FROM system.numbers LIMIT 2");
411+
try (ResultSet rs = stmt.executeQuery("SELECT sleepEachRow(1) FROM system.numbers LIMIT 2")) {
413412
fail("Exception expected");
414413
} catch (Exception e) {
414+
executorService.shutdown();
415+
executorService.awaitTermination(20, TimeUnit.SECONDS);
415416
Assert.assertTrue(conn.isClosed());
416417
Assert.assertFalse(conn.isValid(1000));
417418
conn.close();
419+
418420
}
419421

420422
try {

0 commit comments

Comments
 (0)