Skip to content

Conversation

@desruisseaux
Copy link
Contributor

@desruisseaux desruisseaux commented Dec 14, 2025

This pull request fixes the following bugs in PathSelector:

  • Brace expansion must be applied also to the "/**" path suffix.
  • Detection of "match all" pattern must take brace expansion in account.
  • The optimization for excluding whole directories sometime excludes a directory that shouldn't be excluded.

Those problems were identified by the following steps applied locally:

With this pull request, all above-cited integration tests pass.

Note on refactoring

This commit moves the dirIncludes and dirExcludes matchers to an inner class that implements PathMatcher directly (the indirection level through a lambda function is removed). With this change, the directory matchers are created only if requested and can be provided by a more direct PathMatcher. The new code is a bit more conservative about directory filtering.

@desruisseaux desruisseaux requested a review from gnodet December 14, 2025 11:53
@desruisseaux desruisseaux added java Pull requests that update Java code performance labels Dec 14, 2025
@desruisseaux desruisseaux changed the title Create the directory metchers only if requested and return a more direct PathMatcher for directories Create the directory matchers only if requested and return a more direct PathMatcher for directories Dec 14, 2025
…ect `PathMatcher` for directories.

This commit moves the `dirIncludes` and `dirExcludes` matchers in an inner class that implements `PathMatcher` directly
(the indirection level through a lambda function is removed). The relocated code is mostly identical to previous code,
except for the new `DirectoryPrefiltering.simplify()` method doing the same work as `PathSelector.simplify()`.
@desruisseaux desruisseaux force-pushed the chore/optimize-directory-matcher branch from 49cf69f to 30a48ff Compare December 14, 2025 12:30
* Brace expansion must be applied also to the "/**" path suffix.
* Detection of "match all" pattern must take brace expansion in account.
* Optimization for excluding whole directories should be more conservative.
@desruisseaux
Copy link
Contributor Author

This pull request is no longer an optimization but a real bug fix now. I will edit the description soon.

@desruisseaux desruisseaux changed the title Create the directory matchers only if requested and return a more direct PathMatcher for directories FileSelector.matches(Path) sometime wrong for a file or a directory Dec 14, 2025
@desruisseaux desruisseaux added bug Something isn't working and removed performance labels Dec 14, 2025
@desruisseaux desruisseaux merged commit 10f9c29 into apache:master Dec 15, 2025
1 of 19 checks passed
@github-actions github-actions bot added this to the 4.1.0 milestone Dec 15, 2025
@desruisseaux desruisseaux deleted the chore/optimize-directory-matcher branch December 15, 2025 11:31
desruisseaux added a commit to Geomatys/maven that referenced this pull request Dec 15, 2025
…pache#11551)

* Brace expansion must be applied also to the "/**" path suffix.
* Detection of "match all" pattern must take brace expansion in account.
* Optimization for excluding whole directories should be more conservative.
* Create the directory matchers only if requested and return a more direct `PathMatcher` for directories.
desruisseaux added a commit that referenced this pull request Dec 16, 2025
…11551)

* Brace expansion must be applied also to the "/**" path suffix.
* Detection of "match all" pattern must take brace expansion in account.
* Optimization for excluding whole directories should be more conservative.
* Create the directory matchers only if requested and return a more direct `PathMatcher` for directories.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working java Pull requests that update Java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants