This is an automated email from the ASF dual-hosted git repository.

MartijnVisser pushed a commit to branch release-2.2
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-2.2 by this push:
     new d11e6d93715 [FLINK-39105][rest] Fix 
RestClientTest.testConnectionTimeout to handle environment-dependent exception 
types
d11e6d93715 is described below

commit d11e6d93715753bd02a996b952e656358a3b1aea
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.
    
    (cherry picked from commit fdc2686e33d8dd1a338e3cc1432a6b8b2cad6d71)
---
 .../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 25d685e3189..b786e333058 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.EventLoopGroup;
 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);
         }

Reply via email to