Repository navigation
Fix path sort comparator to be children-first and add test - #9730
Conversation
the path sorting indentation requires child paths to follow right after their parent. But this isn't the case when simply sorting by String. added test note: Moved RandomlyFails annotation from test class to test methods, otherwise the testcase would not run.
|
usually we would revert changes if they don't work as expected. but this is probably small enough to fix during RC. ("famous last words") |
matthiasblaesing
left a comment
There was a problem hiding this comment.
Only eyeballed this, but the approach looks sane to me.
neilcsmith-net
left a comment
There was a problem hiding this comment.
Similarly eyeballed - looks sane. Thanks! Perils of merging things too quickly.
I was curious if sorting with Path was any better, but also seems to sort just by text value without consideration of depth.
Post-release might be worth considering if the comparators should be in FileUtil so they can be used anywhere else that might need this.
|
using Path's comparator directly has the same effect with the potential to be worse: since if Paths are on different filesystem impls the behavior is undefined. (and undefined sorting can throw exceptions in the sort alg - e.g like back when the installer crashed on windows due to weird shell folder File instances) what I initially tried though is to create path anyway, just to iterate through the components -> cleaner code. However this breaks on windows since normalized |
the path sorting indentation requires child paths to follow right after their parent. But this isn't the case when simply sorting by String.
I actually had that feeling that this wouldn't work while looking at the PR #9602 (comment), but I couldn't come up with an example at that time. PR was also merged without full review.
added test
note:
Moved
@RandomlyFailsannotation from test class to test methods, otherwise the new testcase would be running.fixes #9727
targets delivery