From 3689b44815167006212548506b11167a0dee584c Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Tue, 23 Jun 2026 01:01:23 +0000 Subject: [PATCH 1/4] 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/4] 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(); From 5302044999228b5b431874e54104135a2abf7b24 Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Tue, 23 Jun 2026 17:19:26 +0000 Subject: [PATCH 3/4] feedback --- .../cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java | 1 - .../google/cloud/bigquery/jdbc/it/ITStatementTest.java | 10 +++------- 2 files changed, 3 insertions(+), 8 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 5b666e50f30a..f98d6a8d46ca 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,7 +227,6 @@ 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); }); 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 732db93364c2..7f0d833c3cd9 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 @@ -331,13 +331,9 @@ public void testSetTimeout() throws SQLException { assertEquals(0, statement.getQueryTimeout()); statement.setQueryTimeout(1); assertEquals(1, statement.getQueryTimeout()); - try { - statement.executeQuery(selectQuery); - } catch (SQLException e) { - assertEquals( - "BigQueryException during runQuery\nJob execution was cancelled: Job timed out", - e.getMessage()); - } + SQLException e = + assertThrows(SQLException.class, () -> statement.executeQuery(selectQuery)); + assertEquals("BigQueryException during runQuery\nJob execution was cancelled: Job timed out", e.getMessage()); statement.close(); connection.close(); } From 82ced9fddcaaa7e9552adc9065ba5d1a918605d3 Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Tue, 23 Jun 2026 17:39:40 +0000 Subject: [PATCH 4/4] lint --- .../com/google/cloud/bigquery/jdbc/it/ITStatementTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 7f0d833c3cd9..35f3284bab1b 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 @@ -331,9 +331,10 @@ public void testSetTimeout() throws SQLException { assertEquals(0, statement.getQueryTimeout()); statement.setQueryTimeout(1); assertEquals(1, statement.getQueryTimeout()); - SQLException e = - assertThrows(SQLException.class, () -> statement.executeQuery(selectQuery)); - assertEquals("BigQueryException during runQuery\nJob execution was cancelled: Job timed out", e.getMessage()); + SQLException e = assertThrows(SQLException.class, () -> statement.executeQuery(selectQuery)); + assertEquals( + "BigQueryException during runQuery\nJob execution was cancelled: Job timed out", + e.getMessage()); statement.close(); connection.close(); }