Skip to content

[BP-1.20][FLINK-39105][rest] Fix RestClientTest.testConnectionTimeout to handle environment-dependent exception types - #29187

Merged
MartijnVisser merged 1 commit into
apache:release-1.20from
MartijnVisser:FLINK-39105-restclient-socketexception-1.20
Sep 15, 2026
Merged

MartijnVisser merged 1 commit into
apache:release-1.20from
MartijnVisser:FLINK-39105-restclient-socketexception-1.20

Conversation

@MartijnVisser

@MartijnVisser MartijnVisser commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Backport of #27641 (fdc2686), which went to master and release-2.3 but not to this branch.

RestClientTest.testConnectionTimeout asserts ConnectTimeoutException, but a runner without a route to 240.0.0.0 gets an immediate rejection from the OS instead, which Netty reports as AnnotatedSocketException. Both are SocketException subtypes, 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=79075

Verified 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:check and checkstyle:check all pass.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code (Claude Opus 5)

@MartijnVisser MartijnVisser changed the title [FLINK-39105][rest] Fix RestClientTest.testConnectionTimeout to handle environment-dependent exception types [BP-1.20][FLINK-39105][rest] Fix RestClientTest.testConnectionTimeout to handle environment-dependent exception types Sep 15, 2026
@flinkbot

flinkbot commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

…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
MartijnVisser force-pushed the FLINK-39105-restclient-socketexception-1.20 branch from 01cc0f1 to 093b175 Compare September 15, 2026 13:42
@MartijnVisser
MartijnVisser merged commit 02b1666 into apache:release-1.20 Sep 15, 2026
@MartijnVisser
MartijnVisser deleted the FLINK-39105-restclient-socketexception-1.20 branch September 15, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants