[
https://issues.apache.org/jira/browse/SLING-4026?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14179808#comment-14179808
]
JBodkin commented on SLING-4026:
--------------------------------
As far as I can understand, the sling models implementation is successfully
registering the service, followed by the ImmediateComponent binding against the
model and activating the component. Now, the race condition I'm experiencing I
believe is happening is due to the ImmediateComponent active method being fired
before the AdaptorFactory is registered with the AdapterManagerImpl. Therefore,
when the resource attempts to adaptTo, it queries the AdapterManagerImpl which
doesn't know about the presence of the new AdaptorFactory.
The workaround seems to be to use the AdaptorFactory directly, although this is
not ideal.
> Sling Models Race Condition
> ---------------------------
>
> Key: SLING-4026
> URL: https://issues.apache.org/jira/browse/SLING-4026
> Project: Sling
> Issue Type: Bug
> Components: Extensions
> Affects Versions: Sling Models Implementation 1.1.0
> Reporter: JBodkin
> Labels: models
> Attachments: racer.zip
>
>
> During initialization of a bundle, it is possible to encounter a race
> condition in which the BundleTrackerCustomizer::addingBundle(Bundle bundle,
> BundleEvent event) is triggered after the bundle has begun initialization of
> a immediate component.
> {code:java}
> @Component(immediate = true)
> @Service
> public class ExampleImpl {
> @Activate
> public void activate(ComponentContext context) {
> Resource resource = ....
> // Race condition possible here... Could be executed before the
> BundleTracker (ModelPackageBundleListener)
> SlingModelExample example = resource.adaptTo(SlingModelExample);
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)