Repository navigation
fix(gax): do not treat a SocketTimeoutException as a thread interrupt - #14778
Merged
lqiu96 merged 1 commit intoOct 26, 2026
Merged
Conversation
DirectRetryingExecutor.submit catches InterruptedIOException and sets the current thread's interrupt flag. SocketTimeoutException extends InterruptedIOException, so an HTTP connect or read timeout also sets the flag, although no thread was interrupted. setAttemptFuture then calls Future.get, which sees the flag and throws a new InterruptedException. The SocketTimeoutException is lost, and the retry algorithm judges an InterruptedException in its place. A caller sees an InterruptedException from an unknown sender. Catch SocketTimeoutException first and give it to the retry algorithm unchanged. A real interrupt (InterruptedException, other InterruptedIOException, ClosedByInterruptException) keeps the old path. Supersedes googleapis#14578 Related to googleapis#12860 Co-authored-by: Mark Addleman <markaddleman@gmail.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request modifies DirectRetryingExecutor to explicitly catch SocketTimeoutException separately from other InterruptedIOException instances. Because a socket timeout represents a network timeout rather than a thread interruption, handling it separately prevents the thread's interrupt flag from being set, allowing the retry algorithm to properly evaluate and retry the timeout. Corresponding unit tests have been added to verify this behavior. There are no review comments to evaluate, and I have no additional feedback to provide as the implementation is correct and well-tested.
lqiu96
enabled auto-merge (squash)
October 26, 2026 18:50
blakeli0
approved these changes
Oct 26, 2026
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.
Fixes #12860
This PR originally created by @markaddleman (thanks for the contribution!). Re-created on this PR to resolve the merge conflicts.
Summary
Supersedes #14578 (recreated with merge conflicts resolved in
DirectRetryingExecutorTest).DirectRetryingExecutor.submitcatchesInterruptedIOExceptionand sets the current thread's interrupt flag.SocketTimeoutExceptionextendsInterruptedIOException, so an HTTP connect or read timeout also sets the flag, although no thread was interrupted.setAttemptFuturethen callsFuture.get, which sees the flag and throws a newInterruptedException. TheSocketTimeoutExceptionis lost, and the retry algorithm judges anInterruptedExceptionin its place. A caller sees anInterruptedExceptionfrom an unknown sender.This change catches
SocketTimeoutExceptionfirst and passes it to the retry algorithm unchanged. A real interrupt (InterruptedException, any otherInterruptedIOException,ClosedByInterruptException) keeps the current path.