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

javalib Files#walkFileTree method has mutiple opportunities for improvement #3890

Open
7 tasks
LeeTibbert opened this issue Apr 22, 2024 · 0 comments
Open
7 tasks
Assignees

Comments

@LeeTibbert
Copy link
Contributor

LeeTibbert commented Apr 22, 2024

The javalib Files#walkFileTree offers multiple opportunities for improvement (aka defects).
I am doing my best to avoid a philippic.

When the dust settles on walkFileTree, the corresponding walk method should be examined
for similar opportunities.

A non-comprehensive list:

  • The way that SN calls postVisitDirectory() does not match JVM.
    In current code, lll the calls are done after the last element of the
    walk is processed. JVM follows the more expected
    "preVisitDirectory, visitDirectory, postVisitDirectory".

  • Issue Files.walkFileTree does not throw FileSystemLoopException #3744

  • Issue Files.walkFileTree silently swallows NoSuchFileException #3879 Possibly hidden, but not fixed, by PR fix: javalib SimpleFileVisitor#visitFileFailed now matches JVM #3889.

  • Pessimal algorithmic & runtime performance. At least:

    • Testing for same attributes more than once. The tests
      go all the way out to the file system on each call.
      The JVM doc describes doing the much more reasonable one readAttributes()
      to all the attributes likely to be used at once.

    • Currently creating a directory contents stream sits atop algorithmic cost,
      particularly for large directories. The access is not lazy.
      FileHelpers.list(Path): creates an array which is then converted
      to a stream. Every item is touched even if SKIP_SIBLINGS
      happens. This approach eased initial implementation but can
      be improved by the code light of day.

  • code complex far beyond necessity or confidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant