Karl Pauls created SLING-6640:
---------------------------------

             Summary: Race condition in JCR Contentloader deactivate can cause 
NullPointerException.
                 Key: SLING-6640
                 URL: https://issues.apache.org/jira/browse/SLING-6640
             Project: Sling
          Issue Type: Bug
          Components: JCR
    Affects Versions: JCR ContentLoader 2.1.10
            Reporter: Karl Pauls
             Fix For: JCR ContentLoader 2.2.0


The ContentLoaderService registers itself as a SynchronousBundleListener with 
the framework on activate and unregisters in the deactivate method. After it 
unregistered it turns around and first calls:

this.bundleContentLoader.dispose();

and then the bundleContentLoader is set to null. The bundleContentLoader is 
used in the bundleChanged(BundleEvent) callback of the listener interface. 

There seems to be an assumption that there will be no more events received 
after the unregistering as a listener - however, that assumption doesn't hold. 
The framework gets a snapshot of listeners and calls them so there is a window 
where bundleChanged can be invoked after the call to 
bundleContentLoader.dispose() or after it is set to null. 

Both cases can lead to an NPE (either in the bundleChanged directly because the 
bundleContentLoader is null already or inside the bundleContentLoader itself as 
it has been disposed) when there is a race between the service being 
deactivated and a bundle changing state concurrently. 



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to