Skip to content

fix: for #6374 to delete non-empty directories#6375

Merged
jeremylong merged 1 commit intodependency-check:mainfrom
sellersj:delete-nonempty-directory
Jan 9, 2024
Merged

fix: for #6374 to delete non-empty directories#6375
jeremylong merged 1 commit intodependency-check:mainfrom
sellersj:delete-nonempty-directory

Conversation

@sellersj
Copy link
Copy Markdown
Contributor

@sellersj sellersj commented Jan 9, 2024

Fixes Issue #6374

Description of Change

Walk the files to delete using just java.

Have test cases been added to cover the new functionality?

yes

@boring-cyborg boring-cyborg Bot added tests test cases utils changes to utils labels Jan 9, 2024
@sellersj sellersj changed the title for #6374 to delete non-empty directories fix: for #6374 to delete non-empty directories Jan 9, 2024
Copy link
Copy Markdown
Collaborator

@jeremylong jeremylong left a comment

Choose a reason for hiding this comment

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

LGTM

@jeremylong
Copy link
Copy Markdown
Collaborator

Thank you for reporting and fixing the issue. Really appreciate this.

@jeremylong jeremylong merged commit ce29982 into dependency-check:main Jan 9, 2024
@jeremylong jeremylong added this to the 9.0.9 milestone Jan 9, 2024

try {
Files.delete(file.toPath());
Files.walk(file.toPath())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The stream returned by Files.walk should be closed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Interesting... most streams don't need to be closed like this; as documented in the Stream javadoc. Hadn't thought about this possibly being tied to an IO channel. Turns out this isn't uncommon: https://sourcegraph.com/search?q=context:global+content:%22try+%28Stream%3CPath%3E+paths+%3D+Files.walk%28%22+lang:java&patternType=standard&sm=1&groupBy=repo

Fixed with jeremylong/DependencyCheck#6382

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tests test cases utils changes to utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants