Skip to content

Remove erroneous optimization which was skipping the path normalization. - #12617

Closed
desruisseaux wants to merge 1 commit into
apache:maven-4.0.xfrom
Geomatys:fix/remove-erroneous-optimization
Closed

Remove erroneous optimization which was skipping the path normalization.#12617
desruisseaux wants to merge 1 commit into
apache:maven-4.0.xfrom
Geomatys:fix/remove-erroneous-optimization

Conversation

@desruisseaux

Copy link
Copy Markdown
Contributor

That optimization can produce false positive if the pattern appears in the base directory. For example if the base directory is something/target/test-classes and if an include or exclude pattern is **/test-classes where test-classes is another directory as a child of the base directory, the optimization would always consider that there is a match.

That optimization can produce false positive if the pattern appears in the base directory.
For example if the base directory is "something/target/test-classes" and if an include or
exclude pattern is "**/test-classes" where "test-classes" is another directory as a child
of the base directory, the optimization would always consider that there is a match.
@desruisseaux
desruisseaux requested a review from gnodet July 29, 2026 17:02
@desruisseaux desruisseaux added the bug Something isn't working label Jul 29, 2026

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly removes a flawed optimization that skipped path relativization when all patterns started with **, which could cause false-positive matches when the base directory path itself contained segments matching the pattern. The code change is sound.

One suggestion: no regression test is added for the specific false-positive scenario described in the PR body. A test constructing that exact scenario (e.g., base directory = something/target/test-classes with pattern **/test-classes matching a child directory) would prevent reintroduction of the removed optimization and document the edge case for future maintainers.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

@gnodet gnodet closed this Jul 29, 2026
gnodet added a commit that referenced this pull request Jul 29, 2026
…zation

The optimization skipped path relativization when all include/exclude
patterns started with "**". This produced false positives when the base
directory path itself contained a segment matching the pattern (e.g.,
base = "something/target/test-classes" with pattern "**/test-classes/**"
would match every file under the base directory).

Added a regression test for the exact false-positive scenario.

PR: #12621
Original fix by: Martin Desruisseaux (@desruisseaux)
Supersedes: #12617

Closes #12621
@desruisseaux
desruisseaux deleted the fix/remove-erroneous-optimization branch July 29, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants