[
https://issues.apache.org/jira/browse/PARQUET-2154?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gang Wu updated PARQUET-2154:
-----------------------------
Fix Version/s: 1.13.0
> ParquetFileReader should close its input stream when `filterRowGroups` throw
> Exception in constructor
> -----------------------------------------------------------------------------------------------------
>
> Key: PARQUET-2154
> URL: https://issues.apache.org/jira/browse/PARQUET-2154
> Project: Parquet
> Issue Type: Bug
> Reporter: Yang Jie
> Priority: Major
> Fix For: 1.13.0
>
>
>
> {code:java}
> public ParquetFileReader(InputFile file, ParquetReadOptions options) throws
> IOException {
> this.converter = new ParquetMetadataConverter(options);
> this.file = file;
> this.f = file.newStream();
> this.options = options;
> try {
> this.footer = readFooter(file, options, f, converter);
> } catch (Exception e) {
> // In case that reading footer throws an exception in the constructor,
> the new stream
> // should be closed. Otherwise, there's no way to close this outside.
> f.close();
> throw e;
> }
> this.fileMetaData = footer.getFileMetaData();
> this.fileDecryptor = fileMetaData.getFileDecryptor(); // must be called
> before filterRowGroups!
> if (null != fileDecryptor && fileDecryptor.plaintextFile()) {
> this.fileDecryptor = null; // Plaintext file. No need in decryptor
> }
> this.blocks = filterRowGroups(footer.getBlocks());
> this.blockIndexStores = listWithNulls(this.blocks.size());
> this.blockRowRanges = listWithNulls(this.blocks.size());
> for (ColumnDescriptor col :
> footer.getFileMetaData().getSchema().getColumns()) {
> paths.put(ColumnPath.get(col.getPath()), col);
> }
> this.crc = options.usePageChecksumVerification() ? new CRC32() : null;
> } {code}
> During the construction of ParquetFileReader, if `filterRowGroups` method
> throws an exception, it will cause resource leak because when
> `filterRowGroups(footer.getBlocks())` throw an Exception, the open stream
> `{{{}this.f = file.newStream()`{}}} looks unable to be closed.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)