[
https://issues.apache.org/jira/browse/FELIX-550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12601608#action_12601608
]
Felix Meschberger commented on FELIX-550:
-----------------------------------------
In Rev. 662404 I committed a tentative fix for this issue. This fix introduces
a lock guarding access to the component's service registration field. This lock
has the following background and working:
The activateInternal method sets the component state to satisfied (aka ready)
before the component is registered as a service and the internal service
registration field is set.
If now in the time between setting the state to satisified and the service
registration field being set, the component is deactivated -- possibly through
reconfiguration -- the service may not be unregistered because the field is not
set, but re-activation of the component may register the service again thus
resulting in two services being registered, the active and the deactivated.
Which of both is being used is framework implementation dependent but chances
are, the wrong is used resulting in system failure.
To fix this, all access to the service registration field is guarded by a lock.
Only if a thread is able to set the lock flag, can the service registration
field be accessed.
To circumvent the above mentioned situation, the activateInternal method locks
the field _before_ setting the component satisfied. This prevents the
deactivateInternal method from deactivating the component until the service has
been registered and the lock been freed. Only then can the deactivateInternal
method start its deactivation task by unregistering the service.
I deployed a new SNAPSHOT version 1.0.1-20080602.115831-3 including this
tentative fix. Please verify and provide feedback. Thanks.
> SCR registers service component twice after stopping/starting a bundle
> ----------------------------------------------------------------------
>
> Key: FELIX-550
> URL: https://issues.apache.org/jira/browse/FELIX-550
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.0.0
> Environment: JDK 1.6.0_03 / WinXP SP2
> Reporter: Paul Neyens
> Assignee: Felix Meschberger
> Fix For: scr-1.0.1
>
>
> When stopping and starting a bundle (from the shell) that has a component
> which is also registered as a service, this service is registered twice from
> time to time.
> What I am seeing, is that when starting the bundle (after stopping it first),
> the enable method (AbstractComponentManager) is called starting an
> enableInternal' (including an activateInternal) on the component actor thread.
> Approximately at the same time, an update call is made from the configuration
> manager (on some thread from the CM, through method 'update' in
> ImmediateComponentManager's anonymous ManagedService inner class) resulting
> eventually in a call to 'reactivate' which first deactivates
> (deactivateInternal) on the current thread (CM thread). That's where things
> clash, I guess.
> I cannot reproduce this behaviour when logging level is set to debug.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.