Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2008-09-28 19:54:56 +0000
committerSimon Kaegi2008-09-28 19:54:56 +0000
commit9a3b5752c6593ad56b3c6c36e7f17641de4d37f4 (patch)
tree98dbf94a8816d40055d3a1d5d56c2d887ead3e29
parentc8d975d009e6cd84cd82b7cf639ea72749cbb195 (diff)
downloadrt.equinox.bundles-9a3b5752c6593ad56b3c6c36e7f17641de4d37f4.tar.gz
rt.equinox.bundles-9a3b5752c6593ad56b3c6c36e7f17641de4d37f4.tar.xz
rt.equinox.bundles-9a3b5752c6593ad56b3c6c36e7f17641de4d37f4.zip
Bug 248338 Deadlock in ConfigAdmin servicev20080929-1800
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java51
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceTracker.java55
2 files changed, 66 insertions, 40 deletions
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java
index 2d7d89082..ec4dcdd1b 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java
@@ -26,8 +26,11 @@ class ManagedServiceFactoryTracker extends ServiceTracker {
final ConfigurationAdminFactory configurationAdminFactory;
private final ConfigurationStore configurationStore;
+
+ // managedServiceFactoryReferences guards both managedServiceFactories and managedServiceFactoryReferences
private final Map managedServiceFactories = new HashMap();
private final Map managedServiceFactoryReferences = new HashMap();
+
private final SerializedTaskQueue queue = new SerializedTaskQueue("ManagedServiceFactory Update Queue"); //$NON-NLS-1$
public ManagedServiceFactoryTracker(ConfigurationAdminFactory configurationAdminFactory, ConfigurationStore configurationStore, BundleContext context) {
@@ -126,36 +129,46 @@ class ManagedServiceFactoryTracker extends ServiceTracker {
}
}
- private synchronized boolean trackManagedServiceFactory(String factoryPid, ServiceReference reference, ManagedServiceFactory service) {
- if (managedServiceFactoryReferences.containsKey(factoryPid)) {
- configurationAdminFactory.log(LogService.LOG_WARNING, ManagedServiceFactory.class.getName() + " already registered for " + Constants.SERVICE_PID + "=" + factoryPid); //$NON-NLS-1$ //$NON-NLS-2$
- return false;
+ private boolean trackManagedServiceFactory(String factoryPid, ServiceReference reference, ManagedServiceFactory service) {
+ synchronized (managedServiceFactoryReferences) {
+ if (managedServiceFactoryReferences.containsKey(factoryPid)) {
+ configurationAdminFactory.log(LogService.LOG_WARNING, ManagedServiceFactory.class.getName() + " already registered for " + Constants.SERVICE_PID + "=" + factoryPid); //$NON-NLS-1$ //$NON-NLS-2$
+ return false;
+ }
+ managedServiceFactoryReferences.put(factoryPid, reference);
+ managedServiceFactories.put(factoryPid, service);
+ return true;
}
- managedServiceFactoryReferences.put(factoryPid, reference);
- managedServiceFactories.put(factoryPid, service);
- return true;
}
- private synchronized void untrackManagedServiceFactory(String factoryPid, ServiceReference reference) {
- managedServiceFactoryReferences.remove(factoryPid);
- managedServiceFactories.remove(factoryPid);
+ private void untrackManagedServiceFactory(String factoryPid, ServiceReference reference) {
+ synchronized (managedServiceFactoryReferences) {
+ managedServiceFactoryReferences.remove(factoryPid);
+ managedServiceFactories.remove(factoryPid);
+ }
}
- private synchronized ManagedServiceFactory getManagedServiceFactory(String factoryPid) {
- return (ManagedServiceFactory) managedServiceFactories.get(factoryPid);
+ private ManagedServiceFactory getManagedServiceFactory(String factoryPid) {
+ synchronized (managedServiceFactoryReferences) {
+ return (ManagedServiceFactory) managedServiceFactories.get(factoryPid);
+ }
}
- private synchronized ServiceReference getManagedServiceFactoryReference(String factoryPid) {
- return (ServiceReference) managedServiceFactoryReferences.get(factoryPid);
+ private ServiceReference getManagedServiceFactoryReference(String factoryPid) {
+ synchronized (managedServiceFactoryReferences) {
+ return (ServiceReference) managedServiceFactoryReferences.get(factoryPid);
+ }
}
private String getPidForManagedServiceFactory(Object service) {
- for (Iterator it = managedServiceFactories.entrySet().iterator(); it.hasNext();) {
- Entry entry = (Entry) it.next();
- if (entry.getValue() == service)
- return (String) entry.getKey();
+ synchronized (managedServiceFactoryReferences) {
+ for (Iterator it = managedServiceFactories.entrySet().iterator(); it.hasNext();) {
+ Entry entry = (Entry) it.next();
+ if (entry.getValue() == service)
+ return (String) entry.getKey();
+ }
+ return null;
}
- return null;
}
private void asynchDeleted(final ManagedServiceFactory service, final String pid) {
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceTracker.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceTracker.java
index 4b0cf5b3a..37392439f 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceTracker.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceTracker.java
@@ -25,8 +25,11 @@ class ManagedServiceTracker extends ServiceTracker {
final ConfigurationAdminFactory configurationAdminFactory;
private final ConfigurationStore configurationStore;
+
+ // managedServiceReferences guards both managedServices and managedServiceReferences
private final Map managedServices = new HashMap();
private final Map managedServiceReferences = new HashMap();
+
private final SerializedTaskQueue queue = new SerializedTaskQueue("ManagedService Update Queue"); //$NON-NLS-1$
public ManagedServiceTracker(ConfigurationAdminFactory configurationAdminFactory, ConfigurationStore configurationStore, BundleContext context) {
@@ -128,37 +131,47 @@ class ManagedServiceTracker extends ServiceTracker {
}
}
- private synchronized boolean trackManagedService(String pid, ServiceReference reference, ManagedService service) {
- if (managedServiceReferences.containsKey(pid)) {
- String message = ManagedService.class.getName() + " already registered for " + Constants.SERVICE_PID + "=" + pid; //$NON-NLS-1$ //$NON-NLS-2$
- configurationAdminFactory.log(LogService.LOG_WARNING, message);
- return false;
+ private boolean trackManagedService(String pid, ServiceReference reference, ManagedService service) {
+ synchronized (managedServiceReferences) {
+ if (managedServiceReferences.containsKey(pid)) {
+ String message = ManagedService.class.getName() + " already registered for " + Constants.SERVICE_PID + "=" + pid; //$NON-NLS-1$ //$NON-NLS-2$
+ configurationAdminFactory.log(LogService.LOG_WARNING, message);
+ return false;
+ }
+ managedServiceReferences.put(pid, reference);
+ managedServices.put(pid, service);
+ return true;
}
- managedServiceReferences.put(pid, reference);
- managedServices.put(pid, service);
- return true;
}
- private synchronized void untrackManagedService(String pid, ServiceReference reference) {
- managedServiceReferences.remove(pid);
- managedServices.remove(pid);
+ private void untrackManagedService(String pid, ServiceReference reference) {
+ synchronized (managedServiceReferences) {
+ managedServiceReferences.remove(pid);
+ managedServices.remove(pid);
+ }
}
- private synchronized ManagedService getManagedService(String pid) {
- return (ManagedService) managedServices.get(pid);
+ private ManagedService getManagedService(String pid) {
+ synchronized (managedServiceReferences) {
+ return (ManagedService) managedServices.get(pid);
+ }
}
- private synchronized ServiceReference getManagedServiceReference(String pid) {
- return (ServiceReference) managedServiceReferences.get(pid);
+ private ServiceReference getManagedServiceReference(String pid) {
+ synchronized (managedServiceReferences) {
+ return (ServiceReference) managedServiceReferences.get(pid);
+ }
}
- private synchronized String getPidForManagedService(Object service) {
- for (Iterator it = managedServices.entrySet().iterator(); it.hasNext();) {
- Entry entry = (Entry) it.next();
- if (entry.getValue() == service)
- return (String) entry.getKey();
+ private String getPidForManagedService(Object service) {
+ synchronized (managedServiceReferences) {
+ for (Iterator it = managedServices.entrySet().iterator(); it.hasNext();) {
+ Entry entry = (Entry) it.next();
+ if (entry.getValue() == service)
+ return (String) entry.getKey();
+ }
+ return null;
}
- return null;
}
private void asynchUpdated(final ManagedService service, final Dictionary properties) {

Back to the top