Skip to content

DirectoryScanner traverses directories despite limited inclusions #63

Closed
@jjjhhhlll

Description

@jjjhhhlll

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions