FELIX-3637 possibly avoid race condition

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1377082 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
index 29d8493..40171e2 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
@@ -674,7 +674,7 @@
 
     protected void registerService( String[] provides )
     {
-            ServiceRegistration existing = m_serviceRegistration.get();
+        ServiceRegistration existing = m_serviceRegistration.get();
         if ( existing == null )
         {
             log( LogService.LOG_DEBUG, "registering services", null );
@@ -1307,6 +1307,23 @@
                 return;
             }
 
+            // Before creating the implementation object, we are going to
+            // test if all the mandatory dependencies are satisfied
+            if ( !acm.verifyDependencyManagers( acm.getProperties() ) )
+            {
+                acm.log( LogService.LOG_DEBUG, "Not all dependencies satisfied, cannot activate", null );
+                return;
+            }
+
+            // Before creating the implementation object, we are going to
+            // test that the bundle has enough permissions to register services
+            if ( !acm.hasServiceRegistrationPermissions() )
+            {
+                acm.log( LogService.LOG_DEBUG, "Component is not permitted to register all services, cannot activate",
+                    null );
+                return;
+            }
+
             // set satisfied state before registering the service because
             // during service registration a listener may try to get the
             // service from the service reference which may cause a
@@ -1319,25 +1336,6 @@
             final State satisfiedState = acm.getSatisfiedState();
             acm.changeState( satisfiedState );
 
-            // Before creating the implementation object, we are going to
-            // test if all the mandatory dependencies are satisfied
-            if ( !acm.verifyDependencyManagers( acm.getProperties() ) )
-            {
-                acm.log( LogService.LOG_DEBUG, "Not all dependencies satisfied, cannot activate", null );
-                acm.changeState( Unsatisfied.getInstance() );
-                return;
-            }
-
-            // Before creating the implementation object, we are going to
-            // test that the bundle has enough permissions to register services
-            if ( !acm.hasServiceRegistrationPermissions() )
-            {
-                acm.log( LogService.LOG_DEBUG, "Component is not permitted to register all services, cannot activate",
-                    null );
-                acm.changeState( Unsatisfied.getInstance() );
-                return;
-            }
-
             acm.registerComponentService();
 
             // 1. Load the component implementation class