chore(spawn-local-jdk): prune glob tree walks in JDKHomeBasedPatternDetector - #56
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The glob expansion in
JDKHomeBasedPatternDetectorpreviously matched only the full-path glob once a leaf directory was reached, meaning a tree walk had to descend into every directory under the base path even when an early segment could never match. This pulled the giant inline lambda inexpandPattern's stream pipeline out into named static methods (expandPattern,isGlobPattern,expandGlobPattern,indexOfBaseEnd) and added aGlobSegmentshelper plus aPruningGlobVisitor.GlobSegmentssplits a glob suffix into its individual path segments (respecting{...}/[...]groups so a separator nested inside one doesn't get sliced apart) and builds aPathMatcherper fixed-depth segment before the first**, if any.PruningGlobVisitorthen checks each directory against its corresponding segment matcher as soon as it's visited and returnsSKIP_SUBTREEthe moment a segment fails to match, rather than walking the whole subtree first. When a{...}/[...]group spans a path separator, the per-segment assumption breaks down, so the code falls back to unpruned full-glob matching for that pattern, exactly as before.Behavior is otherwise unchanged: plain paths still resolve to themselves without touching the filesystem, non-existent base paths and invalid patterns still yield an empty stream, and
FOLLOW_LINKSplusAccessDeniedExceptionhandling during the walk are preserved.