Skip to content

Commit 031deb0

Browse files
authored
fix: gracefully handle thread interruption in ConnectionImpl to preve… (#4047)
* fix: gracefully handle thread interruption in ConnectionImpl to prevent CI flakes Fixes #3992 * fix: consolidate interrupt checks and handle raw InterruptedException as per review * fix: remove CancelledException check per review feedback
1 parent cbd5d23 commit 031deb0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ConnectionImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,15 @@ private void processArrowStreamAsync(
10691069
}
10701070

10711071
} catch (Exception e) {
1072-
throw BigQueryException.translateAndThrow(e);
1072+
if (e instanceof InterruptedException || e.getCause() instanceof InterruptedException) {
1073+
// Log silently and let it fall through to 'finally' for cleanup.
1074+
// This is the "graceful shutdown".
1075+
logger.log(
1076+
Level.INFO, "Background thread interrupted (Connection Closed). Stopping.");
1077+
Thread.currentThread().interrupt();
1078+
} else {
1079+
throw BigQueryException.translateAndThrow(e);
1080+
}
10731081
} finally { // logic needed for graceful shutdown
10741082
// marking end of stream
10751083
try {

0 commit comments

Comments
 (0)