ResourceProviders not properly released
---------------------------------------

                 Key: SLING-666
                 URL: https://issues.apache.org/jira/browse/SLING-666
             Project: Sling
          Issue Type: Bug
          Components: JCR Resource
    Affects Versions: JCR Resource 2.0.2
            Reporter: Felix Meschberger
            Assignee: Felix Meschberger
             Fix For: JCR Resource 2.0.4


When a ResourceProvider is removed from the system, long-lived 
ResourceResolvers may still hold on to the removed resource provider thus 
referring to  a non-existing service and also preventing the service and its 
classes from being garbage collected. This only happens to resource providers 
attached to the roote resource provider entry in the JcrResourceResolverFactory.

Implementation background: The JcrResourceResolverFactory maintains a root 
resource provider entry, which contains ResourceProviderEntry instances for all 
ResourceProvider instances directly below root. When creating a new 
JcrResourceResolver instance the child entries of the root resource provider 
are handed over to the new JcrResourceResolver instance.

When a resource resolver is added to or removed from the root resource provider 
the entries array of the root resource provider is replaced by a new instance 
reflecting the addition or removal. Still, all JcrResourceResolver instances 
already out there refer to the old entry array, which still contains the 
removed provider (or does not contain the added resource provider yet).

The consequences are problematic for long-lived ResourceResovlers:
  * new resource providers directly attached to the root will never be seen
  * old resource providers directly attached to the root will still be seen 
even after removal

The fix to this problem is to base the JcrResourceResolver returned from the 
JcrResourceResolverFactory on the root resource provider entry itself thus 
using the "live" entries list.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to