Skip to content

IO-811: Files.walk() direct and indirect callers fail to close the re…#489

Closed
labkey-adam wants to merge 3 commits into
apache:masterfrom
labkey-adam:IO-811-Close-Streams
Closed

IO-811: Files.walk() direct and indirect callers fail to close the re…#489
labkey-adam wants to merge 3 commits into
apache:masterfrom
labkey-adam:IO-811-Close-Streams

Conversation

@labkey-adam

@labkey-adam labkey-adam commented Sep 30, 2023

Copy link
Copy Markdown
Contributor

@garydgregory garydgregory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hello @labkey-adam
Thank you for your PR. I'll have to debug later but in the meantime, note the formatting nits.

Comment thread src/main/java/org/apache/commons/io/FileUtils.java Outdated
Comment thread src/main/java/org/apache/commons/io/FileUtils.java Outdated
asfgit pushed a commit that referenced this pull request Oct 1, 2023
internal Stream

Different version of solution from PR #489 by Adam Rauch
asfgit pushed a commit that referenced this pull request Oct 1, 2023
its internal Stream

Different version of solution from PR #489 by Adam Rauch

@garydgregory garydgregory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hello @labkey-adam
Thank you for your PR. I've addressed these issues differently and credited you in changes.xml.

*/
public static Collection<File> listFiles(final File directory, final String[] extensions, final boolean recursive) {
return Uncheck.apply(d -> toList(streamFiles(d, recursive, extensions)), directory);
return Uncheck.apply(d -> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've adopted a variant of this fix in git master. You are credited in changes.xml :-)

return iter.next();
}
};
}, directory);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need for an anonymous class:

return StreamIterator.iterator(Uncheck.get(() -> streamFiles(directory, recursive, extensions)));

@garydgregory

Copy link
Copy Markdown
Member

Closing, see above. Jira ticket resolved.

@labkey-adam labkey-adam deleted the IO-811-Close-Streams branch October 1, 2023 21:01
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.

2 participants