Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure FileReader close()es during avro parse #556

Merged
merged 4 commits into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.nio.file.Path;
import java.util.HashMap;
Expand Down Expand Up @@ -144,13 +145,13 @@ public AvscParseResult parse(Path avscFile) {

public AvscParseResult parse(File avscFile) {
AvscFileParseContext context = new AvscFileParseContext(avscFile, this);
Reader reader;
try {
reader = new FileReader(avscFile);
try (Reader reader = new FileReader(avscFile)) {
return parse(context, reader);
} catch (FileNotFoundException e) {
throw new IllegalStateException("input file " + avscFile.getAbsolutePath() + " not found", e);
} catch (IOException e) {
throw new IllegalStateException("error reading input file " + avscFile.getAbsolutePath(), e);
}
return parse(context, reader);
}

private AvscParseResult parse(AvscFileParseContext context, Reader reader) {
Expand Down
Loading