ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Scanning Resource Collections Several Times
Date Fri, 21 Aug 2009 08:20:22 GMT

I just closed a bug
<> in delete
that really points to a deeper problem.

Delete was scanning the same fileset three times.  Once by innocently
calling getDirectoryScanner (and discarding the results if
includeEmptyDirs and removeNotFollowedSymlinks was false), once by
calling isFileSystemOnly on Resources and once when iterating.

If the fileset contained a modified selector, things couldn't work since
files that had been modified on the first pass wouldn't be modified on
subsequent passes.

While I fixed it for filesets now (by caching the result of the first
scan) it still remains for other resource collections (which might use
modified as a resource selector) and it may very well happen in other
tasks as well.

One culprit is Resources which will create a new MyCollection in
isFileSystemOnly which again invokes size() on all nested resource
collections, scanning them before any iteration is required.  Most other
resource collections extend BaseResourceCollection which has a cache
attribute that is true by default and should avoid the problem.

I'd like to modify Resources to

    (1) lazily initialize size() - Delete never asks for it, for

    (2) Cache the remaining iteration results when initializing size

Does anybody see a problem with this?

There probably are more cases where resource collections could be
scanned multiple times but I'm not sure a complete audit is warranted.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message