Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2014-11-07 22:10:37 +0000
committerThomas Watson2014-11-07 22:10:37 +0000
commit67afa78e319b7bff12529b25790047bd754d23a0 (patch)
tree2ac69a59249abafa47b8ce9c259f6250f931b6c9
parentb206fb1f0cb0104d77a6ec51e8a21f9703b2cb0a (diff)
downloadrt.equinox.framework-67afa78e319b7bff12529b25790047bd754d23a0.tar.gz
rt.equinox.framework-67afa78e319b7bff12529b25790047bd754d23a0.tar.xz
rt.equinox.framework-67afa78e319b7bff12529b25790047bd754d23a0.zip
Bug 449779 - Deadlock within the OSGi framework
- Use AtomicReference for lazy initialize of dynamic misses. This avoids using the common monitor lock for unrelated reasons.
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java27
1 files changed, 13 insertions, 14 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java
index f4c5c5621..53d08b27e 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java
@@ -12,6 +12,7 @@ package org.eclipse.osgi.container;
import java.net.URL;
import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.osgi.container.ModuleRevisionBuilder.GenericInfo;
import org.eclipse.osgi.internal.container.InternalUtils;
import org.osgi.framework.AdminPermission;
@@ -37,7 +38,7 @@ public final class ModuleWiring implements BundleWiring {
private volatile List<ModuleWire> providedWires;
private volatile List<ModuleWire> requiredWires;
private volatile boolean isValid = true;
- private Set<String> dynamicMisses;
+ private final AtomicReference<Set<String>> dynamicMissRef = new AtomicReference<Set<String>>();
ModuleWiring(ModuleRevision revision, List<ModuleCapability> capabilities, List<ModuleRequirement> requirements, List<ModuleWire> providedWires, List<ModuleWire> requiredWires, Collection<String> substitutedPkgNames) {
super();
@@ -436,26 +437,24 @@ public final class ModuleWiring implements BundleWiring {
}
void addDynamicPackageMiss(String packageName) {
- synchronized (monitor) {
- if (dynamicMisses == null) {
- dynamicMisses = new HashSet<String>(5);
- }
- dynamicMisses.add(packageName);
+ Set<String> misses = dynamicMissRef.get();
+ if (misses == null) {
+ dynamicMissRef.compareAndSet(null, Collections.synchronizedSet(new HashSet<String>()));
+ misses = dynamicMissRef.get();
}
+
+ misses.add(packageName);
}
boolean isDynamicPackageMiss(String packageName) {
- synchronized (monitor) {
- return dynamicMisses != null && dynamicMisses.contains(packageName);
- }
+ Set<String> misses = dynamicMissRef.get();
+ return misses != null && misses.contains(packageName);
}
void removeDynamicPackageMisses(Collection<String> packageNames) {
- synchronized (monitor) {
- if (dynamicMisses == null) {
- return;
- }
- dynamicMisses.removeAll(packageNames);
+ Set<String> misses = dynamicMissRef.get();
+ if (misses != null) {
+ misses.removeAll(packageNames);
}
}
}

Back to the top