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

walkFileTree should return consistently absolute or relative paths. #3772

Closed
jean-philippe-martin opened this issue Oct 4, 2018 · 1 comment
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@jean-philippe-martin
Copy link

The expected behavior from Files.walkFileTree is that if the starting path is absolute, then all the visited paths are absolute. If the starting path is relative, then all the visited paths are relative.

However, the output of Files.walkFileTree("/dir/") is something like this:

dir/file.txt
dir/dir2/another.txt
dir/dir2/
/dir/

As you can see, only the last entry is absolute. They should be consistent (in this case, they should be absolute).

jean-philippe-martin added a commit to jean-philippe-martin/gcloud-java that referenced this issue Oct 4, 2018
The expected behavior from Files.walkFileTree is that if the starting path is absolute, then all the visited paths are absolute. If the starting path is relative, then all the visited paths are relative.

This PR adds a test for this behavior, and shows that our current code
fails for an absolute path: it returns a mix of relative and absolute
paths.

This PR also adds a code change to fix the problem, so the actual
behavior matches what is expected.

This should fix issue googleapis#3772
@JustinBeckwith JustinBeckwith added the triage me I really want to be triaged. label Oct 5, 2018
@chingor13 chingor13 added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Oct 5, 2018
@JustinBeckwith JustinBeckwith removed the triage me I really want to be triaged. label Oct 5, 2018
chingor13 pushed a commit that referenced this issue Oct 9, 2018
* walkFiles consistently relative or absolute

The expected behavior from Files.walkFileTree is that if the starting path is absolute, then all the visited paths are absolute. If the starting path is relative, then all the visited paths are relative.

This PR adds a test for this behavior, and shows that our current code
fails for an absolute path: it returns a mix of relative and absolute
paths.

This PR also adds a code change to fix the problem, so the actual
behavior matches what is expected.

This should fix issue #3772

* address issues found by linter

* rename PostTraversalWalker

* apply reviewer feedback
@chingor13
Copy link
Contributor

Fixed in #3773

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants