From 3689b44815167006212548506b11167a0dee584c Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Tue, 23 Jun 2026 01:01:23 +0000 Subject: [PATCH 1/2] chore(bigquery-jdbc): update integration tests to handle different cancellation --- .../google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java | 5 ++++- .../com/google/cloud/bigquery/jdbc/it/ITStatementTest.java | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java index ff9dbf0e7060..00e754ded366 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java @@ -227,12 +227,15 @@ public void testQueryInterruptGracefullyStopsExplicitJob() SQLException e = assertThrows( SQLException.class, () -> bigQueryStatement.execute(query300Seconds)); + System.out.println(e.getMessage()); assertTrue(e.getMessage().contains("User requested cancellation")); threadException.set(false); }); t.start(); // Allow thread to actually initiate the query - Thread.sleep(3000); + // Even when job is created, we might be using `query` API which means if we cancle within first 10 seconds, + // it is similar to Optional job cancellation. Need to wait until after we're in "Wait for job completion" mode. + Thread.sleep(15000); bigQueryStatement.cancel(); // Wait until background thread is finished t.join(); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java index 7094e944893d..461c95d1787d 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java @@ -334,8 +334,7 @@ public void testSetTimeout() throws SQLException { try { statement.executeQuery(selectQuery); } catch (SQLException e) { - assertTrue(true); - assertEquals("SQL execution canceled", e.getMessage()); + assertEquals("BigQueryException during runQuery\nJob execution was cancelled: Job timed out", e.getMessage()); } statement.close(); connection.close(); From c204a513e6cde5ecfbc5775b261f5fa33f6b1118 Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Tue, 23 Jun 2026 01:03:54 +0000 Subject: [PATCH 2/2] lint --- .../cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java | 6 ++++-- .../com/google/cloud/bigquery/jdbc/it/ITStatementTest.java | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java index 00e754ded366..5b666e50f30a 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java @@ -233,8 +233,10 @@ public void testQueryInterruptGracefullyStopsExplicitJob() }); t.start(); // Allow thread to actually initiate the query - // Even when job is created, we might be using `query` API which means if we cancle within first 10 seconds, - // it is similar to Optional job cancellation. Need to wait until after we're in "Wait for job completion" mode. + // Even when job is created, we might be using `query` API which means if we cancle within first + // 10 seconds, + // it is similar to Optional job cancellation. Need to wait until after we're in "Wait for job + // completion" mode. Thread.sleep(15000); bigQueryStatement.cancel(); // Wait until background thread is finished diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java index 461c95d1787d..732db93364c2 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java @@ -334,7 +334,9 @@ public void testSetTimeout() throws SQLException { try { statement.executeQuery(selectQuery); } catch (SQLException e) { - assertEquals("BigQueryException during runQuery\nJob execution was cancelled: Job timed out", e.getMessage()); + assertEquals( + "BigQueryException during runQuery\nJob execution was cancelled: Job timed out", + e.getMessage()); } statement.close(); connection.close();