Skip to content

Commit

Permalink
ensure FileReader close()es during avro parse (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg-builder authored Apr 29, 2024
1 parent 9321e76 commit 49a61e2
Showing 1 changed file with 5 additions and 4 deletions.
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

0 comments on commit 49a61e2

Please sign in to comment.