htsjdk icon indicating copy to clipboard operation
htsjdk copied to clipboard

DiskBackedQueue closeIOResources is broken

Open biotinker opened this issue 5 years ago • 4 comments

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.

biotinker avatar Aug 28 '19 21:08 biotinker

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

lbergelson avatar Aug 28 '19 21:08 lbergelson

Just added a PR with a fix

biotinker avatar Aug 28 '19 21:08 biotinker

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

biotinker avatar Aug 28 '19 21:08 biotinker

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

lbergelson avatar Aug 28 '19 21:08 lbergelson