samtools / htsjdk

A Java API for high-throughput sequencing data (HTS) formats.
http://samtools.github.io/htsjdk/
283 stars 242 forks source link

DiskBackedQueue closeIOResources is broken #1414

Open biotinker opened 5 years ago

biotinker commented 5 years ago

Description of the issue:

When calling clear() on a DiskBackedQueue, rather than deleting the file in question, the path to the temp file is split into its constituent pieces and each treated as file names to be deleted- thus failing to delete the intended file, and potentially deleting random other files.

This is due to the use of IOUtil.deletePaths, which calls Arrays.asList() on whatever you pass it, converting our correct Path into an array of the folder names making it up.

Steps to reproduce

Create a DiskBackedQueue with some directory for TMP_DIR, fill it enough that it spills to disk, and then call clear() on it

Expected behaviour

The temp file should be deleted

Actual behaviour

The folder names making up the path to the temp file are treated as file names, and each of these file names attempt deletion from the current working directory.

lbergelson commented 5 years ago

That sounds nasty... Will fix. Thank you for reporting that.

biotinker commented 5 years ago

Just added a PR with a fix

biotinker commented 5 years ago

https://github.com/samtools/htsjdk/pull/1415/commits

lbergelson commented 5 years ago

Oh, that's even better :) . Thank you.