Skip to content

Commit

Permalink
[ADAM-1974] Close unclosed stream in FastqInputFormat.
Browse files Browse the repository at this point in the history
x
Resolves #1974.
  • Loading branch information
Frank Austin Nothaft authored and heuermh committed Apr 11, 2018
1 parent bfc6a16 commit ad37f5f
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,15 @@ public abstract class FastqInputFormat extends FileInputFormat<Void, Text> {
// so we must actually look at the stream to determine if the file
// is BGZF and splittable or GZIP and not-splittable

try {
InputStream is = filename.getFileSystem(conf).open(filename);

// htsjdk can only test a buffered input stream
// throws an exception if the stream is unbuffered
// why htsjdk doesn't make the function take a buffered input stream instead of
// an input stream, i do not know
splittable = BlockCompressedInputStream.isValidFile(new BufferedInputStream(is));
} catch (Exception e) {
try(InputStream is = filename.getFileSystem(conf).open(filename)) {
// htsjdk can only test a buffered input stream
// throws an exception if the stream is unbuffered
// why htsjdk doesn't make the function take a buffered input stream instead of
// an input stream, i do not know
splittable = BlockCompressedInputStream.isValidFile(new BufferedInputStream(is));
} catch (Exception e) {
splittable = false;
}
}
} else if (codec instanceof SplittableCompressionCodec) {
splittable = true;
} else {
Expand Down

0 comments on commit ad37f5f

Please sign in to comment.