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

   ### Purpose of this PR
   
   Fixes #12231.
   
   `SeaTunnelTask.close()` only caught `IOException` while iterating each flow
   lifecycle's `close()`. An unchecked exception (e.g. `RuntimeException`) 
thrown by an
   earlier lifecycle escaped the teardown loop, so every later lifecycle was 
never
   closed — leaking executors, connections and buffers on task teardown.
   
   ### Changes
   
   `seatunnel-engine/seatunnel-engine-server/.../SeaTunnelTask.java`:
   - Catch `Throwable` (checked `IOException`, unchecked `RuntimeException`, 
and `Error`)
     around each lifecycle's `close()` so a single failure never aborts the 
teardown loop.
   - Keep teardown order; preserve the **first** failure and attach subsequent 
failures as
     **suppressed** via `Throwable#addSuppressed`.
   - Rethrow the first failure at the end: `IOException` stays declared as 
`IOException`;
     other checked/unchecked failures are rethrown via `sneakyThrow`.
   - Javadoc updated to reflect the new semantics.
   
   ### Tests
   
   Extended the existing `SeaTunnelTaskStateTest` with deterministic coverage:
   - `testCloseAttemptsEveryCycleWhenEarlierCycleThrowsUnchecked` — an 
unchecked close
     failure from an earlier lifecycle no longer skips later lifecycles.
   - `testCloseAttemptsEveryCycleWhenEarlierCycleThrowsIoException` — same 
guarantee for a
     checked failure.
   - `testClosePreservesFirstFailureAndAttachesOthersAsSuppressed` — first 
failure is
     preserved as the thrown exception; subsequent failures are attached as 
suppressed.
   
   Change is scoped to task cleanup + its tests; no unrelated refactors, no 
config/API
   changes.
   
   ### Self-review checklist
   
   - [ ] Teardown order preserved; every initialized lifecycle is attempted.
   - [ ] First failure preserved; subsequent failures suppressed.
   - [ ] Deterministic coverage for checked vs unchecked failures and 
multi-failure cases.


-- 
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