Author: gnodet
Date: Thu Aug  1 12:34:58 2013
New Revision: 1509206

URL: http://svn.apache.org/r1509206
Log:
[ARIES-1090] Deadlock with ServiceRecipe

Modified:
    
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java

Modified: 
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java?rev=1509206&r1=1509205&r2=1509206&view=diff
==============================================================================
--- 
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java
 (original)
+++ 
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java
 Thu Aug  1 12:34:58 2013
@@ -86,9 +86,10 @@ public class ServiceRecipe extends Abstr
     private Map registrationProperties;
     private List<ServiceListener> listeners;
     private volatile Object service;
-    /** Only ever access when holding a lock on <code>this</code> */
+    private final Object monitor = new Object();
+    /** Only ever access when holding a lock on <code>monitor</code> */
     private int activeCalls;
-    /** Only ever access when holding a lock on <code>this</code> */
+    /** Only ever access when holding a lock on <code>monitor</code> */
     private boolean quiesce;
     private Collection<DestroyCallback> destroyCallbacks = new 
ArrayList<DestroyCallback>();
     
@@ -448,7 +449,7 @@ public class ServiceRecipe extends Abstr
 
     protected void incrementActiveCalls()
     {
-         synchronized(this) 
+         synchronized(monitor)
          {
                    activeCalls++;      
                    }
@@ -457,7 +458,7 @@ public class ServiceRecipe extends Abstr
        protected void decrementActiveCalls() 
        {
            List<DestroyCallback> callbacksToCall = new 
ArrayList<DestroyCallback>();
-       synchronized(this) 
+       synchronized(monitor)
        {
            activeCalls--;
                            if(quiesce && activeCalls == 0) {
@@ -475,7 +476,7 @@ public class ServiceRecipe extends Abstr
     {
          unregister();
          int calls;
-         synchronized (this) {
+         synchronized (monitor) {
             if(activeCalls != 0)
               destroyCallbacks.add(destroyCallback);
              quiesce = true;


Reply via email to