David Jencks created FELIX-5621:
-----------------------------------
Summary: [DS] event methods setting service properties not thread
safe
Key: FELIX-5621
URL: https://issues.apache.org/jira/browse/FELIX-5621
Project: Felix
Issue Type: Bug
Components: Declarative Services (SCR)
Affects Versions: scr-2.0.8
Reporter: David Jencks
Thanks to Brent Daniels for pointing this out.
Setting service properties from event methods is not thread safe and does not
appear to be possible to make thread safe, as synchronizing will almost
certainly produce deadlocks. This applies to both setting the properties on
ExtComponentContext or returning a properties map.
If ExtComponentContext reliably provided a change counter and a compareAndSet
method then it could be used in e.g.
{code}
int cc;
Dictionary<String, Object> newProps;
do {
cc = etc.getChangeCount();
newProps = new Hashtable<>(ecc.getProperties());
//update properties
} while (!ecc.compareAndSet(cc, newProps)}
{code}
I don't think this can be implemented unless ServiceRegistration provides the
same API. Certainly the felix ServiceRegistration implementation is not thread
safe.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)