This is an automated email from the ASF dual-hosted git repository.
blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/parquet-mr.git
The following commit(s) were added to refs/heads/master by this push:
new 45e3ce5 PARQUET-1368: ParquetFileReader should close its input stream
for the failure in constructor (#510)
45e3ce5 is described below
commit 45e3ce5fd218e4f7ec645c3f2947aa2459fe9c7b
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Wed Aug 8 00:35:38 2018 +0800
PARQUET-1368: ParquetFileReader should close its input stream for the
failure in constructor (#510)
---
.../main/java/org/apache/parquet/hadoop/ParquetFileReader.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git
a/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileReader.java
b/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileReader.java
index 95aaec4..15fe592 100644
---
a/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileReader.java
+++
b/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileReader.java
@@ -686,7 +686,14 @@ public class ParquetFileReader implements Closeable {
this.file = file;
this.f = file.newStream();
this.options = options;
- this.footer = readFooter(file, options, f, converter);
+ 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.blocks = filterRowGroups(footer.getBlocks());
for (ColumnDescriptor col :
footer.getFileMetaData().getSchema().getColumns()) {