Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2009-09-30 20:20:30 +0000
committerThomas Watson2009-09-30 20:20:30 +0000
commit6a74d1110d4ea10f29e868eda9c5b46a738a8d86 (patch)
treef9f7c76bb494c51c0535e3bbb2e9e06d0d1d867a
parente1d5f7217193816df96594c35c87df4a4f8736df (diff)
downloadrt.equinox.framework-6a74d1110d4ea10f29e868eda9c5b46a738a8d86.tar.gz
rt.equinox.framework-6a74d1110d4ea10f29e868eda9c5b46a738a8d86.tar.xz
rt.equinox.framework-6a74d1110d4ea10f29e868eda9c5b46a738a8d86.zip
Bug 290534 ServiceRegistry doesn't remove BundleContextImpl keys from publishedServicesByContext HashMap when list of services becomes empty
-rwxr-xr-xbundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java23
1 files changed, 18 insertions, 5 deletions
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
index 33a1e5fd7..40fc2d22c 100755
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
@@ -586,6 +586,7 @@ public class ServiceRegistry {
/* already unregistered */
}
}
+ removeServiceRegistrations(context); // remove empty list
}
/**
@@ -814,23 +815,26 @@ public class ServiceRegistry {
* @param registration The ServiceRegistration to remove.
*/
/* @GuardedBy("this") */
- void removeServiceRegistration(BundleContextImpl context, ServiceRegistrationImpl serviceReg) {
+ void removeServiceRegistration(BundleContextImpl context, ServiceRegistrationImpl registration) {
// Remove the ServiceRegistrationImpl from the list of Services published by BundleContextImpl.
List contextServices = (List) publishedServicesByContext.get(context);
if (contextServices != null) {
- contextServices.remove(serviceReg);
+ contextServices.remove(registration);
}
// Remove the ServiceRegistrationImpl from the list of Services published by Class Name.
- String[] clazzes = serviceReg.getClasses();
+ String[] clazzes = registration.getClasses();
for (int i = 0, size = clazzes.length; i < size; i++) {
String clazz = clazzes[i];
List services = (List) publishedServicesByClass.get(clazz);
- services.remove(serviceReg);
+ services.remove(registration);
+ if (services.isEmpty()) { // remove empty list
+ publishedServicesByClass.remove(clazz);
+ }
}
// Remove the ServiceRegistrationImpl from the list of all published Services.
- allPublishedServices.remove(serviceReg);
+ allPublishedServices.remove(registration);
}
/**
@@ -888,6 +892,15 @@ public class ServiceRegistry {
}
/**
+ * Remove Service Registrations in the data structure by BundleContext.
+ *
+ * @param context The BundleContext for which to remove Service Registrations.
+ */
+ private synchronized void removeServiceRegistrations(BundleContextImpl context) {
+ publishedServicesByContext.remove(context);
+ }
+
+ /**
* Modify a List<ServiceRegistrationImpl> in place to a List<ServiceReferenceImpl>.
*
* @param result The input List<ServiceRegistrationImpl>.

Back to the top