Repository navigation
HTTPCLIENT-2436: Fall back to remaining addresses after a TLS failure (RFC 8305) - #3336
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
Member
Author
|
@Sharawey74 please check |
Member
|
@arturobernalg All these verbose comments are AI generated, are they not? I have absolutely no problem with change-sets generated by AI or with AI assistance of AI but I am not sure comments like that bring much. They will likely start rotting as soon as the same code gets touched by someone who does not use AI. |
Thanks @arturobernalg. My two commits from #3332 apply cleanly on top of this one, so I'll open them as two separate PRs as @ok2c asked: the certificate fail-fast change, then the real-server test on top of it. |
arturobernalg
force-pushed
the
fix-tls-fallback-happy-eyeballs
branch
from
December 2, 2026 15:59
3575749 to
2577fc8
Compare
… (RFC 8305) MultihomeIOSessionRequester only retried a TCP-level connect failure across the resolved addresses; a TLS failure on an address that had already connected at the TCP level, racing or not, ended the whole attempt instead of trying the others, the same regression apache#936 fixed for the classic client. Adds a SessionValidator hook run on every connected session before it is accepted, shared by the sequential path and the race's post-win fallback, mirroring DefaultHttpClientConnectionOperator's connectSequentially. A deterministic peer-certificate failure stays final on every path, since the same certificate would be presented on the remaining addresses too. Hardens cancellation around the new fallback attempts: executeNext() checks future.isDone() at both its entry points, under a single ReentrantLock per connectSequentially() run shared across all its attempts, so a same-thread reentrant rejection and a cross-thread one can never race on which attempt is tracked. Race's own six synchronized blocks are converted the same way. A TlsStrategy that reports an outcome and then throws is a no-op on the second signal instead of double-advancing the fallback. A cancel can still be lost underneath this, in httpcore5: SingleCoreIOReactor#processConnectionRequest initiates the connect before assigning the IOSessionRequest a closeable, and never assigns one at all when the connect completes immediately, so a cancel() landing in that window closes nothing. A separate, narrower check-then-set race in ComplexFuture#setDependency is also unclosed. Both belong in httpcore5, out of scope here; an HTTPCORE ticket will follow. TestHappyEyeballsTlsFallbackAsync's cancelDuringFallbackAfterRealTlsFailure_abortsPendingAttempt hits that window often enough on loopback to be unusable as written, independent of the happyEyeballs parameter, and is disabled until it's fixed. TestHttpAsyncMinimalTlsHandshake.testTlsHandshakeFailure is pinned to a literal address: "localhost" may resolve to both 127.0.0.1 and ::1, and a TLS failure is no longer necessarily final for the last-tried address.
arturobernalg
force-pushed
the
fix-tls-fallback-happy-eyeballs
branch
from
December 2, 2026 16:16
2577fc8 to
d7c7e30
Compare
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.
SessionValidator falls back to the next address on a TLS failure (sequential or Happy-Eyeballs), closing the same gap #936 fixed for classic. Cancel-during-fallback test disabled: real core race in SingleCoreIOReactor losing cancel(), HTTPCORE ticket to follow.