diff --git a/adam-core/src/main/java/org/bdgenomics/adam/io/FastqInputFormat.java b/adam-core/src/main/java/org/bdgenomics/adam/io/FastqInputFormat.java index 4c3f5a9da6..64ec0f69fb 100644 --- a/adam-core/src/main/java/org/bdgenomics/adam/io/FastqInputFormat.java +++ b/adam-core/src/main/java/org/bdgenomics/adam/io/FastqInputFormat.java @@ -66,17 +66,15 @@ public abstract class FastqInputFormat extends FileInputFormat { // 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 {