For some strange reason, the ComponentProcessor gets an extraneous
duplicate update from the ConfigAdmin when running the netvirt
integration/CSIT which causes it to restart the container b/c it
thinks there was an update. There is no cfg file so both updates
pass a null Properties. Oddly, I do not see this behavior when
installing the toaster feature from the controller karaf.
I added logic to store the last update and only restart if it
changed. In my testing though, the ConfigAdmin does not notify
unless a change actually occurred.
Change-Id: I692dbd7fcaf921b90f828059d6104138c16a0508
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.List;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.aries.blueprint.ComponentDefinitionRegistry;
import org.apache.aries.blueprint.ComponentDefinitionRegistryProcessor;
import org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder;
import org.apache.aries.blueprint.ComponentDefinitionRegistry;
import org.apache.aries.blueprint.ComponentDefinitionRegistryProcessor;
import org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder;
// Register a ManagedService so we get updates from the ConfigAdmin when the cfg file corresponding
// to the persistentId changes.
final ManagedService managedService = new ManagedService() {
// Register a ManagedService so we get updates from the ConfigAdmin when the cfg file corresponding
// to the persistentId changes.
final ManagedService managedService = new ManagedService() {
- private volatile boolean initialUpdate = true;
+ private final AtomicBoolean initialUpdate = new AtomicBoolean(true);
+ private volatile Dictionary<String, ?> previousProperties;
@Override
public void updated(final Dictionary<String, ?> properties) {
@Override
public void updated(final Dictionary<String, ?> properties) {
// The first update occurs when the service is registered so ignore it as we want subsequent
// updates when it changes. The ConfigAdmin will send an update even if the cfg file doesn't
// yet exist.
// The first update occurs when the service is registered so ignore it as we want subsequent
// updates when it changes. The ConfigAdmin will send an update even if the cfg file doesn't
// yet exist.
- if (initialUpdate) {
- initialUpdate = false;
- } else {
+ if (!initialUpdate.compareAndSet(true, false) && !Objects.equals(previousProperties, properties)) {
blueprintContainerRestartService.restartContainerAndDependents(bundle);
}
blueprintContainerRestartService.restartContainerAndDependents(bundle);
}
+
+ previousProperties = properties;