Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing bad behavior in IOUtil.deletePaths #1416

Merged
merged 1 commit into from
Aug 30, 2019

Conversation

lbergelson
Copy link
Member

  • The method IOUtil.deletePaths(Iterable<Path>) had pathological behavior.

    • A Path is an Iterable<Path> which iterates over the subpaths in the Path.
      Therefore, this version was binding instead of the varargs version that takes Path...
      Then the method would try to delete all of the subpaths in the path which doesn't delete the intended target and could delete random files.
    • This is obviously bad behavior. Fixed by adding an explicit check to see if it's called with a single Path.
    • Extracted a new method deletePath which is used for deleting a single path.
  • Fixes #DiskBackedQueue closeIOResources is broken #1414

* The method IOUtil.deletePaths(Iterable<Path>) had pathological.
  * A Path is an Iterable<Path> which iterates over the subpaths in the Path.
     Therefore, this version was binding instead of the varargs version that takes Path...
     Then the method would try to delete all of the subpaths in the path.
  * This is obviously bad behavior.  Fixed by adding an explicit check to see if it's called with a single Path.
  * Extracted a new method deletePath which is used for deleting a single path.

* Fixes ##1414
@codecov-io
Copy link

codecov-io commented Aug 29, 2019

Codecov Report

Merging #1416 into master will increase coverage by 0.003%.
The diff coverage is 100%.

@@               Coverage Diff               @@
##              master     #1416       +/-   ##
===============================================
+ Coverage     68.124%   68.127%   +0.003%     
- Complexity      8379      8381        +2     
===============================================
  Files            573       573               
  Lines          33982     33985        +3     
  Branches        5668      5668               
===============================================
+ Hits           23150     23153        +3     
  Misses          8643      8643               
  Partials        2189      2189
Impacted Files Coverage Δ Complexity Δ
src/main/java/htsjdk/samtools/util/IOUtil.java 58.413% <100%> (+0.302%) 120 <5> (+2) ⬆️
...ain/java/htsjdk/samtools/util/DiskBackedQueue.java 64.22% <100%> (ø) 29 <0> (ø) ⬇️

Copy link
Collaborator

@cmnbroad cmnbroad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@lbergelson lbergelson merged commit e1bbd34 into master Aug 30, 2019
@lbergelson lbergelson deleted the lb_fix_behavior_of_deletPaths branch August 30, 2019 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants