You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by dj...@apache.org on 2013/01/25 18:36:46 UTC

svn commit: r1438607 - /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java

Author: djencks
Date: Fri Jan 25 17:36:46 2013
New Revision: 1438607

URL: http://svn.apache.org/viewvc?rev=1438607&view=rev
Log:
FELIX-3870 Use write lock around modified method to assure activate/modify/deactivate don't overlap

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java?rev=1438607&r1=1438606&r2=1438607&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java Fri Jan 25 17:36:46 2013
@@ -609,39 +609,47 @@ public class ImmediateComponentManager<S
         // 4. call method (nothing to do when failed, since it has already been logged)
         //   (call with non-null default result to continue even if the
         //    modify method call failed)
-        updateTargets( props );
-        final MethodResult result = invokeModifiedMethod();
-        if ( result == null )
+        obtainWriteLock( "ImmediateComponentManager.modify" );
+        try
         {
-            // log an error if the declared method cannot be found
-            log( LogService.LOG_ERROR, "Declared modify method ''{0}'' cannot be found, configuring by reactivation",
-                    new Object[] {getComponentMetadata().getModified()}, null );
-            return false;
-        }
+            final MethodResult result = invokeModifiedMethod();
+            updateTargets( props );
+            if ( result == null )
+            {
+                // log an error if the declared method cannot be found
+                log( LogService.LOG_ERROR, "Declared modify method ''{0}'' cannot be found, configuring by reactivation",
+                        new Object[] {getComponentMetadata().getModified()}, null );
+                return false;
+            }
 
-        // 5. update the target filter on the services now, this may still
-        // result in unsatisfied dependencies, in which case we abort
-        // this dynamic update and have the component be deactivated
-        if ( !verifyDependencyManagers() )
-        {
-            log( LogService.LOG_ERROR,
-                    "Updating the service references caused at least on reference to become unsatisfied, deactivating component",
-                    null );
-            return false;
-        }
+            // 5. update the target filter on the services now, this may still
+            // result in unsatisfied dependencies, in which case we abort
+            // this dynamic update and have the component be deactivated
+            if ( !verifyDependencyManagers() )
+            {
+                log( LogService.LOG_ERROR,
+                        "Updating the service references caused at least on reference to become unsatisfied, deactivating component",
+                        null );
+                return false;
+            }
 
-        // 6. update service registration properties if we didn't just do it
-        if ( result.hasResult() )
-        {
-            setServiceProperties( result );
+            // 6. update service registration properties if we didn't just do it
+            if ( result.hasResult() )
+            {
+                setServiceProperties( result );
+            }
+            else
+            {
+                updateServiceRegistration();
+            }
+
+            // 7. everything set and done, the component has been updated
+            return true;
         }
-        else
+        finally
         {
-            updateServiceRegistration();
+            releaseWriteLock( "ImmediateComponentManager.modify" );
         }
-
-        // 7. everything set and done, the component has been updated
-        return true;
     }
 
     protected MethodResult invokeModifiedMethod()