[
https://issues.apache.org/jira/browse/ARIES-1732?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16135035#comment-16135035
]
Grzegorz Grzybek commented on ARIES-1732:
-----------------------------------------
After several tests (I'll commit new blueprint-itests related to blueprint.cm
anyway), I think we just can't add "do not accept null properties" to
{{CmPropertyPlaceholder}}...
First - when configadmin is not available, we won't get the properties anyway
(at least not without using {{<cm:default-properties>}}). We won't get them
when the PID is not available as well.
Blueprint container is designed to wait for namespace handlers and services,
but not for PID configurations.
When BP container is started and PID is not available and then later becomes
available, using {{<cm:property-placeholder update-strategy="reload">}} solves
the problem.
When BP container is started and PID configuration *is* available, but bound to
different location, we *have* race condition, where:
{code:java}
CmUtils.getProperties(reg.getRegistration().getReference(), key)
{code}
returns valid properties, but:
{code:java}
private static class ConfigurationWatcher implements ManagedService {
private ServiceRegistration registration;
private List<ManagedObject> list = new
CopyOnWriteArrayList<ManagedObject>();
public ConfigurationWatcher() {
}
public void updated(final Dictionary props) throws ConfigurationException {
// Run in a separate thread to avoid re-entrance
new Thread() {
public void run() {
for (ManagedObject cm : list) {
cm.updated(props);
}
}
}.start();
}
{code}
is getting {{null}} because
{{org.apache.felix.cm.impl.ConfigurationManager#canReceive()}} returns
{{false}} - but this is the problem of e.g., fileinstall not allowing to set
location for CM configuration.
I believe that a solution to problem where {{ManagedService.updated()}} is
getting null due to wrong location is not changing CmPropertyPlaceholder, but
rather ensuring that given PID has _multiple location_ set (OSGi R5 CMPN,
104.4.1 Location Binding).
> blueprint-cm - race condition
> -----------------------------
>
> Key: ARIES-1732
> URL: https://issues.apache.org/jira/browse/ARIES-1732
> Project: Aries
> Issue Type: Bug
> Components: Blueprint
> Reporter: Paolo Antinori
> Assignee: Grzegorz Grzybek
>
> There is a possible race condition in
> `org.apache.aries.blueprint.compendium.cm.CmPropertyPlaceholder` and
> `org.apache.aries.blueprint.compendium.cm.ManagedObjectManager`
> There are situations where `ConfigAdmin` service might not be available and
> returns `null` when queried for the initial `config`.
> In other cases instead, `CmPropertyPlaceholder` receives updates from
> `ConfigAdmin` thread even before it has completed it's initialization.
> The code doesn't discriminate if `config` is `null` or not, and treats any
> value as valid, marking `CmPropertyPlaceholder` instance as initialized.
> This leads to spotty errors.
> The suggested fix, that simply prevents that `update(null)` invocation mark
> the `CmPropertyPlaceholder` instance as initialized, addresses the issue.
> Code here:
> https://github.com/apache/aries/compare/trunk...paoloantinori:ENTESB-7141?expand=1
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)