wombatu-kun commented on code in PR #17150:
URL: https://github.com/apache/iceberg/pull/17150#discussion_r3555960756
##########
core/src/main/java/org/apache/iceberg/avro/AvroIterable.java:
##########
@@ -83,7 +83,16 @@ public CloseableIterator<D> iterator() {
.setRowPositionSupplier(
Suppliers.memoize(() ->
AvroIO.findStartingRowPos(file::newStream, start)));
}
- fileReader = new AvroRangeIterator<>(fileReader, start, end);
+ try {
+ fileReader = new AvroRangeIterator<>(fileReader, start, end);
+ } catch (RuntimeException e) {
+ try {
+ fileReader.close();
+ } catch (IOException closeException) {
+ e.addSuppressed(closeException);
Review Comment:
No test exercises this line: `readerClosedWhenRangeSyncFails` leaves
`close()` unstubbed on the `DataFileReader` mock
(`core/src/test/java/org/apache/iceberg/avro/TestAvroIterable.java:76`), so it
returns normally and the inner `catch (IOException closeException)` is never
entered.
Add a case that stubs `doThrow(new IOException()).when(fileReader).close();`
alongside the failing `sync`, and assert the suppressed exception on the
rethrown `RuntimeIOException`.
`api/src/test/java/org/apache/iceberg/util/TestExceptionUtil.java:57-60` has
the idiom: `.extracting(e ->
Arrays.asList(e.getSuppressed())).asInstanceOf(InstanceOfAssertFactories.LIST).hasSize(1)`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]