Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DirectoryScanner traverses directories despite limited inclusions #63

Closed
jjjhhhlll opened this issue Mar 26, 2019 · 1 comment
Closed
Assignees
Milestone

Comments

@jjjhhhlll
Copy link

jjjhhhlll commented Mar 26, 2019

We have a directory with lots of files (enough to consume all jvm memory if traversed by DirectoryScanner).

We use an inclusion filter with ant-style pattern like this:

<includes>
  <include>dir1/*/somefile.txt</include>
</includes>

Note: 'dir1' is NOT the very large directory.

Non-matching directories should end up here: https://github.com/codehaus-plexus/plexus-utils/blob/master/src/main/java/org/codehaus/plexus/util/DirectoryScanner.java#L484 and then based off not matching the includes, the traversal should stop.

But it seems the 'couldHoldIncluded(name)' call is always returning true due to a bug in the implementation.

https://github.com/codehaus-plexus/plexus-utils/blob/master/src/main/java/org/codehaus/plexus/util/MatchPattern.java#L97

Here it constructs 'altStr' based off 'source' and not 'str' which causes a match of the pattern against the pattern, which always return true. I believe the intention is to normalize the path separator in 'str' not 'source' when constructing 'altStr'.

cheers,
Jon

@belingueres
Copy link
Contributor

Good catch! I will work on a patch.

belingueres referenced this issue in belingueres/plexus-utils Mar 27, 2019
- Added tests exposing the issue.
- Fixed code with the change suggested by the reporter.
@michael-o michael-o self-assigned this Jul 3, 2019
@michael-o michael-o added this to the 3.2.1 milestone Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants