This is an automated email from the ASF dual-hosted git repository.
martijnvisser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/master by this push:
new fdc2686e33d [FLINK-39105][rest] Fix
RestClientTest.testConnectionTimeout to handle environment-dependent exception
types
fdc2686e33d is described below
commit fdc2686e33d8dd1a338e3cc1432a6b8b2cad6d71
Author: Martijn Visser <[email protected]>
AuthorDate: Wed Feb 18 11:06:00 2026 +0100
[FLINK-39105][rest] Fix RestClientTest.testConnectionTimeout to handle
environment-dependent exception types
The test connects to 192.0.2.1 (RFC 5737 TEST-NET-1) 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.
---
.../test/java/org/apache/flink/runtime/rest/RestClientTest.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git
a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestClientTest.java
b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestClientTest.java
index 3b2f96d7912..a15913ef09a 100644
---
a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestClientTest.java
+++
b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestClientTest.java
@@ -37,7 +37,6 @@ import org.apache.flink.util.function.CheckedSupplier;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.flink.shaded.netty4.io.netty.channel.Channel;
-import org.apache.flink.shaded.netty4.io.netty.channel.ConnectTimeoutException;
import
org.apache.flink.shaded.netty4.io.netty.channel.DefaultSelectStrategyFactory;
import
org.apache.flink.shaded.netty4.io.netty.channel.MultiThreadIoEventLoopGroup;
import org.apache.flink.shaded.netty4.io.netty.channel.SelectStrategy;
@@ -54,6 +53,7 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.SocketException;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
@@ -111,9 +111,13 @@ class RestClientTest {
EmptyMessageParameters.getInstance(),
EmptyRequestBody.getInstance());
+ // Depending on the environment, connecting to a non-routable
address may fail with
+ // either a ConnectTimeoutException (timeout fires before the OS
responds) or a
+ // SocketException such as "Network is unreachable" (OS rejects
immediately).
+ // Both are SocketException subtypes.
FlinkAssertions.assertThatFuture(future)
.eventuallyFailsWith(ExecutionException.class)
- .withCauseInstanceOf(ConnectTimeoutException.class)
+ .withCauseInstanceOf(SocketException.class)
.extracting(Throwable::getCause,
as(InstanceOfAssertFactories.THROWABLE))
.hasMessageContaining(unroutableIp);
}