FELIX-5178: Make some component parameters volatile.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1731992 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java
index d3890bd..4b5fccc 100644
--- a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java
+++ b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java
@@ -64,34 +64,34 @@
/**
* Component callback used to inject an added dependency.
*/
- protected String m_add;
+ protected volatile String m_add;
/**
* Component callback invoked when the dependency has changed.
*/
- protected String m_change;
+ protected volatile String m_change;
/**
* Component callback invoked when the dependency becomes unavailable.
*/
- protected String m_remove;
+ protected volatile String m_remove;
/**
* Can this Dependency be auto configured in the component instance fields ?
*/
- protected boolean m_autoConfig = true;
+ protected volatile boolean m_autoConfig = true;
/**
* The Component field name where the Dependency can be injected (null means any field with a compatible type
* will be injected).
*/
- protected String m_autoConfigInstance;
+ protected volatile String m_autoConfigInstance;
/**
* Indicates if the setAutoConfig method has been invoked. This flag is used to force autoconfig to "false"
* when the setCallbacks method is invoked, unless the setAutoConfig method has been called.
*/
- protected boolean m_autoConfigInvoked;
+ protected volatile boolean m_autoConfigInvoked;
/**
* Has this Dependency been started by the Component implementation ? Volatile because the getState method
@@ -103,17 +103,17 @@
* The object instance on which the dependency callbacks are invoked on. Null means the dependency will be
* injected to the Component implementation instance(s).
*/
- protected Object m_callbackInstance;
+ protected volatile Object m_callbackInstance;
/**
* Tells if the dependency service properties have to be propagated to the Component service properties.
*/
- protected boolean m_propagate;
+ protected volatile boolean m_propagate;
/**
* The propagate callback instance that is invoked in order to supply dynamically some dependency service properties.
*/
- protected Object m_propagateCallbackInstance;
+ protected volatile Object m_propagateCallbackInstance;
/**
* The propagate callback method that is invoked in order to supply dynamically some dependency service properties.
diff --git a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java
index f424e17..c341112 100644
--- a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java
+++ b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java
@@ -42,14 +42,14 @@
*/
public class BundleDependencyImpl extends AbstractDependency<BundleDependency> implements BundleDependency, BundleTrackerCustomizer, ComponentDependencyDeclaration {
private BundleTracker m_tracker;
- private int m_stateMask = Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE;
+ private volatile int m_stateMask = Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE;
private Bundle m_bundleInstance;
- private Filter m_filter;
- private long m_bundleId = -1;
+ private volatile Filter m_filter;
+ private volatile long m_bundleId = -1;
private Object m_nullObject;
- private boolean m_propagate;
- private Object m_propagateCallbackInstance;
- private String m_propagateCallbackMethod;
+ private volatile boolean m_propagate;
+ private volatile Object m_propagateCallbackInstance;
+ private volatile String m_propagateCallbackMethod;
public BundleDependencyImpl() {
}
diff --git a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
index 29e5992..3fed28e 100644
--- a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
+++ b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
@@ -139,7 +139,7 @@
/**
* The object used to create the component. Can be a class name, or the component implementation instance.
*/
- private Object m_componentDefinition;
+ private volatile Object m_componentDefinition;
/**
* The component instance.
diff --git a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
index 3749fac..9eee05c 100644
--- a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
+++ b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
@@ -46,15 +46,15 @@
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class ConfigurationDependencyImpl extends AbstractDependency<ConfigurationDependency> implements ConfigurationDependency, ManagedService {
- private Dictionary<String, Object> m_settings;
- private String m_pid;
+ private volatile Dictionary<String, Object> m_settings;
+ private volatile String m_pid;
private ServiceRegistration m_registration;
private volatile Class<?> m_configType;
- private MetaTypeProviderImpl m_metaType;
+ private volatile MetaTypeProviderImpl m_metaType;
private final AtomicBoolean m_updateInvokedCache = new AtomicBoolean();
private final Logger m_logger;
private final BundleContext m_context;
- private boolean m_needsInstance = true;
+ private volatile boolean m_needsInstance = true;
public ConfigurationDependencyImpl() {
this(null, null);
@@ -273,9 +273,7 @@
InvocationUtil.invokeUpdated(m_component.getExecutor(), () -> invokeUpdated(settings));
// At this point, we have accepted the configuration.
- synchronized (this) {
- m_settings = settings;
- }
+ m_settings = settings;
if ((oldSettings == null) && (settings != null)) {
// Notify the component that our dependency is available.
diff --git a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceAdapterImpl.java b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceAdapterImpl.java
index 3cfc117..853f20b 100644
--- a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceAdapterImpl.java
+++ b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceAdapterImpl.java
@@ -36,9 +36,9 @@
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class ResourceAdapterImpl extends FilterComponent {
- private Object m_callbackInstance = null;
- private String m_callbackChanged = "changed";
- private String m_callbackAdded = "setResource";
+ private final Object m_callbackInstance;
+ private final String m_callbackChanged;
+ private final String m_callbackAdded;
private final String m_resourceFilter;
/**
diff --git a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java
index 4e9df67..00e6358 100644
--- a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java
+++ b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java
@@ -47,7 +47,7 @@
*/
public class ServiceDependencyImpl extends AbstractDependency<ServiceDependency> implements ServiceDependency, ServiceTrackerCustomizer {
protected volatile ServiceTracker m_tracker;
- protected String m_swap;
+ protected volatile String m_swap;
protected volatile Class<?> m_trackedServiceName;
private volatile String m_trackedServiceFilter;
private volatile String m_trackedServiceFilterUnmodified;
@@ -55,9 +55,9 @@
private volatile Object m_defaultImplementation;
private volatile Object m_defaultImplementationInstance;
private volatile Object m_nullObject;
- private boolean m_debug = false;
- private String m_debugKey;
- private long m_trackedServiceReferenceId;
+ private volatile boolean m_debug = false;
+ private volatile String m_debugKey;
+ private volatile long m_trackedServiceReferenceId;
public ServiceDependency setDebug(String debugKey) {
m_debugKey = debugKey;