Author: fmeschbe
Date: Thu Jan 26 10:49:57 2012
New Revision: 1236132

URL: http://svn.apache.org/viewvc?rev=1236132&view=rev
Log:
FELIX-3317 A delayed component in state registered may become active during 
service registration. This is a valid state change and must be accounted for. 
Also improve information on the service registration about to be removed.

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

Modified: 
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java?rev=1236132&r1=1236131&r2=1236132&view=diff
==============================================================================
--- 
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
 (original)
+++ 
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
 Thu Jan 26 10:49:57 2012
@@ -35,6 +35,7 @@ import org.apache.felix.scr.impl.metadat
 import org.apache.felix.scr.impl.metadata.ServiceMetadata;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServicePermission;
 import org.osgi.framework.ServiceReference;
@@ -511,7 +512,7 @@ public abstract class AbstractComponentM
 
             synchronized ( this )
             {
-                if ( currentState == preRegistrationState && 
this.m_serviceRegistration == null )
+                if ( (currentState == preRegistrationState || currentState == 
Active.getInstance()) && this.m_serviceRegistration == null )
                 {
                     this.m_serviceRegistration = sr;
                     return;
@@ -524,8 +525,19 @@ public abstract class AbstractComponentM
             // both situations indicate the current registration is not to
             // be used
 
-            log( LogService.LOG_WARNING, "State changed from " + 
preRegistrationState + " to " + currentState
-                + " during service registration; unregistering service " + sr, 
null );
+            if ( isLogEnabled( LogService.LOG_WARNING ) )
+            {
+                StringBuffer msg = new StringBuffer();
+                msg.append( "State changed from " ).append( 
preRegistrationState );
+                msg.append( " to " ).append( currentState );
+                msg.append( " during service registration; unregistering 
service [" );
+                ServiceReference ref = sr.getReference();
+                msg.append( Arrays.asList( ( String[] ) ref.getProperty( 
Constants.OBJECTCLASS ) ) );
+                msg.append( ',' );
+                msg.append( ref.getProperty( Constants.SERVICE_ID ) );
+                msg.append( ']' );
+                log( LogService.LOG_WARNING, msg.toString(), null );
+            }
 
             try
             {


Reply via email to