Commit fdc2686
committed
[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.1 parent 45c62ca commit fdc2686
File tree
1 file changed
+6
-2
lines changed- flink-runtime/src/test/java/org/apache/flink/runtime/rest
1 file changed
+6
-2
lines changedLines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
114 | 118 | | |
115 | 119 | | |
116 | | - | |
| 120 | + | |
117 | 121 | | |
118 | 122 | | |
119 | 123 | | |
| |||
0 commit comments