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 committed Apr 11, 2018
1 parent 04fb7e3 commit 8f20f0a
Showing 1 changed file with 8 additions and 10 deletions.
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 8f20f0a

Please sign in to comment.