corgy-w opened a new pull request, #12326:
URL: https://github.com/apache/seatunnel/pull/12326
### What
`IcebergSinkWriter.close()` now releases the table loader even when closing
the record writer fails.
### Why
`close()` was:
```java
if (writer != null) {
writer.close();
}
icebergTableLoader.close();
```
`RecordWriter.close()` is a real flush/finalize step for the Iceberg
implementations. When it throws, `icebergTableLoader.close()` is skipped
entirely, so the catalog client and the Hadoop `FileSystem` it owns stay alive
for the rest of the task, and the close failure is the only thing reported —
the leak is invisible.
Same defect class as the merged Neo4j fix (#11750, "close the session and
driver even when close fails part way"): release every resource, propagate the
first failure, attach the later ones as suppressed. The same pattern also
exists in other connectors (for example `TableStoreSourceReader.close()` and
`DorisSinkWriter.close()`), which is out of scope for this PR.
### Fix
Both resources are always released; the first failure propagates as
`IOException`/`RuntimeException` (unchanged exception type for callers), any
later failure is attached with `addSuppressed`.
### How verified
- New tests in `IcebergSinkWriterTest` (Mockito mocks injected into the
private `writer` field with `ReflectionUtils`):
- `testCloseReleasesTableLoaderWhenRecordWriterFails`
- `testCloseReleasesRecordWriterWhenTableLoaderFails`
- With this change: `Tests run: 7, Failures: 0, Errors: 0, Skipped: 0` (`mvn
-o -pl seatunnel-connectors-v2/connector-iceberg test
-Dtest=IcebergSinkWriterTest`).
- Reverting only `IcebergSinkWriter.java`:
`testCloseReleasesTableLoaderWhenRecordWriterFails` fails with `Wanted but not
invoked: tableLoader.close()`.
### Compatibility
No option name, default value, or public API change. Close failures are
still propagated with the same exception types; only the resource-release
guarantee is stronger.
--
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]