jglobus / JGlobus

jGlobus is a collection of Java client libraries for Globus® Toolkit security, GRAM, and GridFTP.
http://www.globus.org/toolkit/jglobus/
Apache License 2.0
24 stars 44 forks source link

Avoid memory leak and stale information when scanning directories #141

Closed paulmillar closed 9 years ago

paulmillar commented 9 years ago

The GlobusPathMatchingResourcePatternResolver class can scan a filesystem for files matching some pattern. Instances of this class maintain an internal list of matches. Successive calls to the getResources method will append matching file paths and return the complete list. Note that (currently) there is no mechanism to reset the internal list.

The ResourceSigningPolicyStore reuses the same Resolver instance for all loadPolicy method calls, with three bad effects:

  1. files are included multiple times, potentially resulting in loading a policy file multiple times;
  2. the result list will always increase, eventually triggering an OOM;
  3. if a file is removed then, as the Resolver's result list will continue to have the file, an error will be reported. The negative cache alieviates this third problem so an error is reported once every 10 hours.

This patch modifies the code so loadPolicy method creates a new Resolver for each loadPolicy method call. There is no additional filesystem overhead (the previous code would also always scan the directory), but the results are now accurate and do not contain duplicates.

Target: master Request: 2.1 Request: 2.0