fix: properly handle thread interrupts during gRPC channel shutdown#159
Merged
KaviarasuSakthivadivel merged 2 commits intomainfrom Mar 5, 2026
Merged
Conversation
carsheng
approved these changes
Mar 5, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #159 +/- ##
============================================
+ Coverage 82.73% 82.79% +0.06%
Complexity 1347 1347
============================================
Files 111 111
Lines 4055 4058 +3
Branches 413 413
============================================
+ Hits 3355 3360 +5
+ Misses 510 508 -2
Partials 190 190
🚀 New features to boost your workflow:
|
mkaufmann
approved these changes
Mar 5, 2026
mkaufmann
reviewed
Mar 5, 2026
jdbc-core/src/main/java/com/salesforce/datacloud/jdbc/core/JdbcDriverStubProvider.java
Show resolved
Hide resolved
d241348 to
46d1504
Compare
mkaufmann
approved these changes
Mar 5, 2026
When InterruptedException is caught during channel.awaitTermination(), the thread's interrupt status is cleared. This fix restores the interrupt status following Java best practices to ensure proper interrupt propagation. Changes: - Call shutdownNow() immediately when interrupted - Restore interrupt status with Thread.currentThread().interrupt() - Improve logging to distinguish timeout from interrupt - Follow pattern from gRPC Java examples This ensures thread pools and upstream callers can properly detect that the thread was interrupted.
46d1504 to
0f4674f
Compare
When InterruptedException is caught during channel.awaitTermination(), the thread's interrupt status is cleared. This fix restores the interrupt status following Java best practices to ensure proper interrupt propagation. Changes: - Use graceful shutdown() to allow async queries to complete on server - Call shutdownNow() immediately when interrupted or on timeout - Restore interrupt status with Thread.currentThread().interrupt() - Improve logging to distinguish timeout from interrupt scenarios This hybrid approach: - Supports async query patterns (submit query, close connection, fetch later) - Fixes interrupt handling for thread pool shutdowns - Ensures proper interrupt propagation to upstream callers
carsheng
approved these changes
Mar 5, 2026
afurdell
approved these changes
Mar 5, 2026
KaviarasuSakthivadivel
pushed a commit
that referenced
this pull request
Mar 6, 2026
🤖 I have created a release *beep* *boop* --- ## [0.42.2](v0.42.1...v0.42.2) (2026-03-05) ### Bug Fixes * allow refresh-token auth without userName ([#157](#157)) ([97bc515](97bc515)) * properly handle thread interrupts during gRPC channel shutdown ([#159](#159)) ([b0a96d1](b0a96d1)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When InterruptedException is caught during channel.awaitTermination(),
the thread's interrupt status is cleared. This fix restores the interrupt
status following Java best practices to ensure proper interrupt propagation.
Changes:
This ensures thread pools and upstream callers can properly detect
that the thread was interrupted.