Skip to content

Commit 9208ba9

Browse files
author
Paultagoras
committed
Update StatementTest.java
1 parent 3459dcc commit 9208ba9

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -480,24 +480,29 @@ public void testConnectionExhaustion() throws Exception {
480480

481481
@Test(groups = { "integration" })
482482
public void testConcurrentCancel() throws Exception {
483+
int maxNumConnections = 3;
484+
483485
try (Connection conn = getJdbcConnection()) {
484486
try (StatementImpl stmt = (StatementImpl) conn.createStatement()) {
485487
stmt.executeQuery("SELECT number FROM system.numbers LIMIT 10000000000");
486488
stmt.cancel();
487489
}
488-
try (StatementImpl stmt = (StatementImpl) conn.createStatement()) {
489-
new Thread(() -> {
490-
try {
491-
ResultSet rs = stmt.executeQuery("SELECT number FROM system.numbers LIMIT 10000000000");
492-
rs.next();
493-
log.info(rs.getObject(1).toString());
494-
} catch (SQLException e) {
495-
log.error("Error in thread", e);
496-
}
497-
}).start();
498-
499-
Thread.sleep(1000);
500-
stmt.cancel();
490+
for (int i = 0; i < maxNumConnections; i++) {
491+
try (StatementImpl stmt = (StatementImpl) conn.createStatement()) {
492+
final int threadNum = i;
493+
log.info("Starting thread {}", threadNum);
494+
new Thread(() -> {
495+
try {
496+
ResultSet rs = stmt.executeQuery("SELECT number FROM system.numbers LIMIT 10000000000");
497+
rs.next();
498+
log.info(rs.getObject(1).toString());
499+
} catch (SQLException e) {
500+
log.error("Error in thread {}", threadNum, e);
501+
}
502+
}).start();
503+
504+
stmt.cancel();
505+
}
501506
}
502507
}
503508
}

0 commit comments

Comments
 (0)