Skip to content

Commit 8aa3e74

Browse files
committed
make sure stream gets closed
1 parent dac6ba4 commit 8aa3e74

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

library/src/main/java/bio/terra/pfb/PfbReader.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ public static String showMetadata(String fileLocation) throws IOException {
4949

5050
public static List<String> show(String fileLocation) throws IOException {
5151
List<String> data = new ArrayList<>();
52-
try {
53-
DataFileStream<GenericRecord> records = PfbReader.getGenericRecordsStream(fileLocation);
5452

53+
try (DataFileStream<GenericRecord> records = PfbReader.getGenericRecordsStream(fileLocation)) {
5554
while (records.hasNext()) {
5655
data.add(convertEnum(records.next().toString()));
5756
}
@@ -61,6 +60,9 @@ public static List<String> show(String fileLocation) throws IOException {
6160
}
6261
}
6362

63+
/**
64+
* DataFileStream implements Closeable and must be closed by the client code.
65+
**/
6466
public static DataFileStream<GenericRecord> getGenericRecordsStream(String fileLocation)
6567
throws IOException {
6668
GenericDatumReader<GenericRecord> datumReader = new GenericDatumReader<>();

0 commit comments

Comments
 (0)