Remove erroneous path normalization optimization + regression test - #12621
Conversation
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.
…tches a pattern Constructs the exact scenario from the PR description: base directory "something/target/test-classes" with pattern "**/test-classes/**" would falsely match files in sibling directories when path relativization was skipped. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet
left a comment
There was a problem hiding this comment.
LGTM — clean, well-tested bugfix that removes a flawed path-relativization optimization introduced in #10935.
The first commit (from desruisseaux via #12617) correctly fixes the false-positive matching by making relativization unconditional, and the second commit adds a precise regression test covering the exact scenario (base directory containing test-classes as a segment, pattern **/test-classes/**).
The commit structure properly preserves attribution while superseding #12617 (which lacked a test and had maintainer push disabled).
The regression test is well-constructed: it verifies both the true-positive case (file inside a test-classes/ child directory matches) and the false-positive prevention (file in a sibling other/ directory does not match just because the base path contains test-classes).
CI full-build checks pass on all platforms (macOS/Windows/Linux, JDK 17/21/25). Integration tests still pending at time of review.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
…zation Forward-port of #12621 from maven-4.0.x to master. 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. Original fix by: Martin Desruisseaux (@desruisseaux) Closes #12622
Summary
This PR incorporates the fix from #12617 (by @desruisseaux) and adds the regression test requested in the review.
needRelativizeoptimization inPathSelectorthat skipped path relativization when all patterns started with**. The optimization produced false positives when the base directory path itself contained a segment matching the pattern.testNoFalsePositiveWhenBaseDirectoryMatchesPatternthat constructs the exact scenario from the PR description — base directorysomething/target/test-classeswith pattern**/test-classes/**falsely matching files in sibling directories.Supersedes #12617 (maintainer push was disabled on the fork, so the test could not be added directly to that PR).
Test plan
PathSelectorTesttests pass with the fix🤖 Generated with Claude Code