aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1421113 - in /aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container: AbstractServiceReferenceRecipe.java ReferenceListRecipe.java ReferenceRecipe.java
Date Thu, 13 Dec 2012 08:11:22 GMT
Author: gnodet
Date: Thu Dec 13 08:11:21 2012
New Revision: 1421113

URL: http://svn.apache.org/viewvc?rev=1421113&view=rev
Log:
[ARIES-962] Deadlock while stopping OSGi container

Modified:
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceListRecipe.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java?rev=1421113&r1=1421112&r2=1421113&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
Thu Dec 13 08:11:21 2012
@@ -83,6 +83,7 @@ public abstract class AbstractServiceRef
     /** The list of listeners for this reference.  This list will be lazy created */
     protected List<Listener> listeners;
 
+    protected final Object monitor = new Object();
     private final List<ServiceReference> references = new ArrayList<ServiceReference>();
     private final AtomicBoolean started = new AtomicBoolean();
     private final AtomicBoolean satisfied = new AtomicBoolean();
@@ -129,7 +130,7 @@ public abstract class AbstractServiceRef
                 satisfied.set(optional);
                 // Synchronized block on references so that service events won't interfere
with initial references tracking
                 // though this may not be sufficient because we don't control ordering of
those events
-                synchronized (references) {
+                synchronized (monitor) {
                     getBundleContextForServiceLookup().addServiceListener(this, getOsgiFilter());
                     ServiceReference[] references = getBundleContextForServiceLookup().getServiceReferences(null,
getOsgiFilter());
                     if (references != null) {
@@ -149,7 +150,7 @@ public abstract class AbstractServiceRef
 
     public void stop() {
         if (started.compareAndSet(true, false)) {
-            synchronized (references) {
+            synchronized (monitor) {
                 getBundleContextForServiceLookup().removeServiceListener(this);
                 doStop();
                 for (Iterator<ServiceReference> it = references.iterator(); it.hasNext();)
{
@@ -330,7 +331,7 @@ public abstract class AbstractServiceRef
     private void serviceAdded(ServiceReference ref) {
         LOGGER.debug("Tracking reference {} for OSGi service {}", ref, getOsgiFilter());
         if (isStarted()) {
-            synchronized (references) {
+            synchronized (monitor) {
                 if (references.contains(ref)) {
                     return;
                 }
@@ -344,7 +345,7 @@ public abstract class AbstractServiceRef
     private void serviceModified(ServiceReference ref) {
         // ref must be in references and must be satisfied
         if (isStarted()) {
-            synchronized (references) {
+            synchronized (monitor) {
                 if (references.contains(ref)) {
                     track(ref);
                 }
@@ -357,7 +358,7 @@ public abstract class AbstractServiceRef
             LOGGER.debug("Untracking reference {} for OSGi service {}", ref, getOsgiFilter());
             boolean removed;
             boolean satisfied;
-            synchronized (references) {
+            synchronized (monitor) {
                 removed = references.remove(ref);
                 satisfied = optional || !references.isEmpty();
             }
@@ -439,13 +440,13 @@ public abstract class AbstractServiceRef
     }
     
     public List<ServiceReference> getServiceReferences() {
-        synchronized (references) {
+        synchronized (monitor) {
             return new ArrayList<ServiceReference>(references);
         }
     }
 
     public ServiceReference getBestServiceReference() {
-        synchronized (references) {
+        synchronized (monitor) {
             int length = references.size();
             if (length == 0) { /* if no service is being tracked */
                 return null;

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceListRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceListRecipe.java?rev=1421113&r1=1421112&r2=1421113&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceListRecipe.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceListRecipe.java
Thu Dec 13 08:11:21 2012
@@ -50,8 +50,7 @@ public class ReferenceListRecipe extends
     private final List<ManagedCollection> collections = new ArrayList<ManagedCollection>();
     private final DynamicCollection<ServiceDispatcher> storage = new DynamicCollection<ServiceDispatcher>();
     private final List<ServiceDispatcher> unboundDispatchers = new ArrayList<ServiceDispatcher>();
-    private final Object monitor = new Object();
-    
+
     public ReferenceListRecipe(String name,
                          ExtendedBlueprintContainer blueprintContainer,
                          ReferenceListMetadata metadata,

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java?rev=1421113&r1=1421112&r2=1421113&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java
Thu Dec 13 08:11:21 2012
@@ -61,7 +61,6 @@ public class ReferenceRecipe extends Abs
     private volatile ServiceReference trackedServiceReference;
     private volatile Object trackedService;
     private Object defaultBean;
-    private final Object monitor = new Object();
 
     private final Collection<Class<?>> proxyChildBeanClasses;
     private final Collection<WeakReference<Voidable>> proxiedChildren;



Mime
View raw message