Skip to content

Commit

Permalink
Fix reader resource leakage (#51)
Browse files Browse the repository at this point in the history
* Fix resource leakage withing streams
  • Loading branch information
Minutis authored Jun 13, 2024
1 parent 6612a57 commit d8f2e72
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ public ParquetLookupReader(Configuration conf, String path) {
public Stream<Map<String, Object>> find(List<ColumnValueFilter> filters, int limit) {
LOG.debug("Reading: {} with filters {}", path, filters);
try (var reader = prepareReader(filters)) {
return Streams.stream(Iterators.limit(new ParquetIterator(reader), limit));
return Streams.stream(Iterators.limit(new ParquetIterator<>(reader), limit)).onClose(() -> {
try {
reader.close();
} catch (IOException e) {
LOG.error("Failed to close ParquetReader", e);
}
});
} catch (IOException e) {
throw new IllegalStateException("Failed building reader", e);
}
Expand Down

0 comments on commit d8f2e72

Please sign in to comment.