SiriusTL666 opened a new pull request, #12974:
URL: https://github.com/apache/seatunnel/pull/12974

   ## Purpose of this pull request
   
   Bound the connect timeout for the Socket connector. `SocketSourceReader` 
called `socket.connect(address, 0)`, and in Java a connect timeout of `0` means 
**wait indefinitely**. If the socket server was down, unreachable, or its port 
filtered, `open()` never returned, so the reader task hung with no error to 
observe. The sink's `SocketClient` had the same gap via `new Socket(host, 
port)`, which also applies no connect timeout.
   
   ## Changes
   
   - **New options** in `SocketCommonOptions`, shared by source and sink:
     - `connect_timeout_ms` — default `10000`
     - `read_timeout_ms` — default `0`
   - **Source**: connect with `connect_timeout_ms`; `SO_TIMEOUT` uses 
`read_timeout_ms`.
   - **Sink**: replace `new Socket(host, port)` with `Socket()` + 
`connect(address, connect_timeout_ms)`.
   - **Docs**: en/zh source and sink option tables.
   - **Tests**: defaults and overrides, plus a regression test pointing at 
TEST-NET-1.
   
   ### Why `read_timeout_ms` defaults to 0
   
   `SocketSourceReader` blocks in `reader.read(...)` on purpose — it is a 
long-lived streaming source. Setting a non-zero `SO_TIMEOUT` by default would 
turn every idle period into a failure, which would be a behaviour change well 
beyond this bug. The default keeps current semantics; users who want idle 
detection can opt in. `connect_timeout_ms` is bounded by default because 
waiting forever on a dead host is never useful.
   
   ## Does this PR introduce any new feature?
   
   Yes — two optional connector options. Existing configurations are unaffected 
except that a connect to a dead host now fails after 10s instead of hanging.
   
   ## Does this PR enhance an existing feature?
   
   Fixes a hang.
   
   ## Verdict
   
   - [x] I have read the [Contributing 
Guide](https://github.com/apache/seatunnel/blob/dev/CONTRIBUTING.md)
   - [x] Tests pass locally
   - [x] No breaking change for existing configs
   
   ### Verification
   
   Built and tested with JDK 17 against `dev`:
   
   - `mvn -pl seatunnel-connectors-v2/connector-socket test` — 8/8 pass.
   - `spotless:check` — clean.
   
   The regression test was verified in both directions:
   
   | Code | `open()` elapsed |
   |---|---|
   | `connect(address, 0)` (before) | 21047 ms, test fails |
   | `connect(address, connect_timeout_ms)` | ~1.4 s, test passes |
   
   Note on the local environment, in case CI differs: this project's Lombok 
1.18.36 annotation processor crashes on JDK 25 (`ExceptionInInitializerError` 
in `LombokProcessor`), so the build above used JDK 17. Worth knowing if anyone 
else hits a compiler failure with no diagnostics.
   
   ## Related issues
   
   No existing issue covers this; I found it while auditing connectors for 
unbounded network waits. Happy to file one first if the project prefers that — 
let me know.
   
   Note: PR #12572 also touches `SocketSourceFactory` (validation only). This 
change adds options to the same `optionRule()`; if #12572 lands first I will 
rebase.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to