anxkhn opened a new pull request, #3662: URL: https://github.com/apache/parquet-java/pull/3662
### Rationale for this change `ParquetRewriter.getFileReaders` opens a `TransParquetFileReader` for each input file into a local list. If opening a later file throws `IOException`, it is rethrown as `IllegalArgumentException` without closing the readers already opened for the earlier files, so their `SeekableInputStream` handles leak. `ParquetRewriter.close()` only ends the writer and does not close the input readers, so nothing else releases them either. A single corrupt, missing, or permission-denied file among several valid inputs therefore leaks up to N open input streams per failed rewrite/merge/join setup. ### What changes are included in this PR? In `getFileReaders`, close the readers already opened before rethrowing, using `org.apache.parquet.util.AutoCloseables.close(...)` so every reader is released and any close failures are aggregated as suppressed exceptions on the original `IllegalArgumentException`. This matches the existing cleanup idiom in the module. The change is limited to the `catch (IOException)` block; the success path is unchanged. ### Are these changes tested? Yes. A new `ParquetRewriterTest` case (`testInputFileReadersClosedWhenLaterInputFileFailsToOpen`) supplies a valid input file (wrapped so it records whether the stream it hands out is closed) followed by an `InputFile` whose `newStream()` throws, asserts that constructing the `ParquetRewriter` throws `IllegalArgumentException`, and asserts the first reader's stream was closed. It fails on the pre-fix code (the first stream is left open) and passes with the fix. The full `ParquetRewriterTest` class passes (`Tests run: 96, Failures: 0, Errors: 0`). ### Are there any user-facing changes? No public API changes. The only behavioral difference is that a failed `ParquetRewriter` setup no longer leaks the input streams it had already opened. <!-- No GitHub issue filed; using the template's MINOR: fallback. --> -- 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]
