[BP-1.20][FLINK-39105][rest] Fix RestClientTest.testConnectionTimeout to handle environment-dependent exception types - #29187
Merged
MartijnVisser merged 1 commit intoSep 15, 2026
Conversation
Collaborator
…e environment-dependent exception types The test connects to 240.0.0.0 (reserved space, RFC 1112) with a 1ms connection timeout and asserts ConnectTimeoutException. On CI runners without a route to this address, the OS immediately returns "Network is unreachable" (AnnotatedSocketException) instead of timing out, causing the test to fail. Both ConnectTimeoutException and AnnotatedSocketException are SocketException subtypes, so the assertion now uses SocketException as the expected cause type. The existing hasMessageContaining(unroutableIp) check still verifies the failure is for the correct destination. Note: on environments where the OS rejects immediately, the configured connection timeout is never exercised. The test still verifies that connection failures propagate correctly, but does not validate the timeout code path on those environments. A more robust approach would require simulating a non-completing TCP handshake, which is not portable. (cherry picked from commit fdc2686)
MartijnVisser
force-pushed
the
FLINK-39105-restclient-socketexception-1.20
branch
from
September 15, 2026 13:42
01cc0f1 to
093b175
Compare
MartijnVisser
deleted the
FLINK-39105-restclient-socketexception-1.20
branch
September 15, 2026 18:22
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.
Backport of #27641 (fdc2686), which went to master and release-2.3 but not to this branch.
RestClientTest.testConnectionTimeoutassertsConnectTimeoutException, but a runner without a route to240.0.0.0gets an immediate rejection from the OS instead, which Netty reports asAnnotatedSocketException. Both areSocketExceptionsubtypes, so the assertion now expects that.Last occurrence on this branch in the nightly of 2026-09-15,
test_cron_adaptive_scheduler core: https://dev.azure.com/apache-flink/apache-flink/_build/results?buildId=79075Verified on this branch: under a forced no-route condition the test fails on the base commit and passes with this change, and
RestClientTest, the architecture tests,spotless:checkandcheckstyle:checkall pass.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Claude Opus 5)