Skip to content

Commit

Permalink
[FLINK-11371] The AvroParquetReader is not being closed
Browse files Browse the repository at this point in the history
  • Loading branch information
Fokko Driesprong authored and aljoscha committed Jan 17, 2019
1 parent 76dd766 commit 0a54983
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,13 @@ private static <T> void validateResults(File folder, GenericData dataModel, List

private static <T> List<T> readParquetFile(File file, GenericData dataModel) throws IOException {
InputFile inFile = HadoopInputFile.fromPath(new org.apache.hadoop.fs.Path(file.toURI()), new Configuration());
ParquetReader<T> reader = AvroParquetReader.<T>builder(inFile).withDataModel(dataModel).build();

ArrayList<T> results = new ArrayList<>();
T next;
while ((next = reader.read()) != null) {
results.add(next);
try (ParquetReader<T> reader = AvroParquetReader.<T>builder(inFile).withDataModel(dataModel).build()) {
T next;
while ((next = reader.read()) != null) {
results.add(next);
}
}

return results;
Expand Down

0 comments on commit 0a54983

Please sign in to comment.