felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1549723 - in /felix/trunk/scr/src: main/java/org/apache/felix/scr/impl/manager/ test/java/org/apache/felix/scr/integration/
Date Tue, 10 Dec 2013 00:53:43 GMT
Author: djencks
Date: Tue Dec 10 00:53:42 2013
New Revision: 1549723

URL: http://svn.apache.org/r1549723
Log:
FELIX-4350 Fix race between activation and deactivation. Problem with ServiceTracker exposed
and ignored

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java?rev=1549723&r1=1549722&r2=1549723&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
Tue Dec 10 00:53:42 2013
@@ -263,6 +263,7 @@ public class DependencyManager<S, T> imp
 
         public void removedService( ServiceReference<T> serviceReference, RefPair<T>
refPair, int trackingCount )
         {
+            refPair.setDeleted( true );
             if ( !isOptional() )
             {
                 if (getTracker().isEmpty())
@@ -351,6 +352,7 @@ public class DependencyManager<S, T> imp
         public void removedService( ServiceReference<T> serviceReference, RefPair<T>
refPair, int trackingCount )
         {
             m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic
removed {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            refPair.setDeleted( true );
             boolean unbind = isOptional() || !getTracker().isEmpty();
             if ( unbind )
             {
@@ -469,6 +471,7 @@ public class DependencyManager<S, T> imp
         public void removedService( ServiceReference<T> serviceReference, RefPair<T>
refPair, int trackingCount )
         {
             m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy
removed {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            refPair.setDeleted( true );
             tracked( trackingCount );
             if ( isActive() )
             {
@@ -566,6 +569,7 @@ public class DependencyManager<S, T> imp
         public void removedService( ServiceReference<T> serviceReference, RefPair<T>
refPair, int trackingCount )
         {
             m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticReluctant
removed {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            refPair.setDeleted( true );
             tracked( trackingCount );
             Collection<RefPair<T>> refs = this.refs.get();
             if ( isActive() && refs != null )
@@ -737,6 +741,7 @@ public class DependencyManager<S, T> imp
         public void removedService( ServiceReference<T> serviceReference, RefPair<T>
refPair, int trackingCount )
         {
             m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleDynamic
removed {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            refPair.setDeleted( true );
             boolean deactivate = false;
             boolean untracked = true;
             RefPair<T> oldRefPair = null;
@@ -937,6 +942,10 @@ public class DependencyManager<S, T> imp
         public void removedService( ServiceReference<T> serviceReference, RefPair<T>
refPair, int trackingCount )
         {
             m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic
removed {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            if ( refPair != null ) //TODO needs investigation
+            {
+                refPair.setDeleted( true );
+            }
             this.trackingCount = trackingCount;
             tracked( trackingCount );
             boolean reactivate;
@@ -1427,7 +1436,7 @@ public class DependencyManager<S, T> imp
             new Object[]{ getName(), success, refs }, null );
         for ( RefPair<T> refPair : refs )
         {
-            if ( !refPair.isFailed() )
+            if ( !refPair.isDeleted() && !refPair.isFailed() )
             {
                 if ( !doInvokeBindMethod( componentInstance, refPair ) )
                 {

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java?rev=1549723&r1=1549722&r2=1549723&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java Tue Dec 10
00:53:42 2013
@@ -33,6 +33,7 @@ public class RefPair<T>
     private AtomicReference<T> serviceObjectRef = new AtomicReference<T>();
 
     private boolean failed;
+    private volatile boolean deleted;
 
     public RefPair( ServiceReference<T> ref )
     {
@@ -74,6 +75,15 @@ public class RefPair<T>
         return failed;
     }
 
+    public boolean isDeleted()
+    {
+        return deleted;
+    }
+
+    public void setDeleted(boolean deleted)
+    {
+        this.deleted = deleted;
+    }
 
     @Override
     public String toString()

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java?rev=1549723&r1=1549722&r2=1549723&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
(original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
Tue Dec 10 00:53:42 2013
@@ -254,13 +254,17 @@ public abstract class ComponentTestBase
 
     protected static void delay()
     {
+        delay(300);
+    }
+
+    protected static void delay(int millis)
+    {
         try
         {
-            Thread.sleep( 300 );
+            Thread.sleep(millis);
         }
-        catch ( InterruptedException ie )
+        catch (InterruptedException ie)
         {
-            // dont care
         }
     }
 

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java?rev=1549723&r1=1549722&r2=1549723&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java Tue
Dec 10 00:53:42 2013
@@ -45,44 +45,35 @@ public class Felix4350Test extends Compo
         // uncomment to enable debugging of this test class
 //                paxRunnerVmOption = DEBUG_VM_OPTION;
         descriptorFile = "/integration_test_FELIX_4350.xml";
-        restrictedLogging = true;
         //comment to get debug logging if the test fails.
 //        DS_LOGLEVEL = "warn";
     }
 
-    @Inject
-    protected BundleContext bundleContext;
-
     @Test
-    @Ignore
     public void test_unbind_while_activating_single_static()
     {
         doTest("SingleStatic");
     }
 
     @Test
-    @Ignore
     public void test_unbind_while_activating_single_dynamic()
     {
         doTest("SingleDynamic");
     }
 
     @Test
-    @Ignore
     public void test_unbind_while_activating_multiple_dynamic()
     {
         doTest("MultipleDynamic");
     }
 
     @Test
-    @Ignore
     public void test_unbind_while_activating_multiple_static_greedy()
     {
         doTest("MultipleStaticGreedy");
     }
 
     @Test
-    @Ignore
     public void test_unbind_while_activating_multiple_static_reluctant()
     {
         doTest("MultipleStaticReluctant");
@@ -126,15 +117,4 @@ public class Felix4350Test extends Compo
         TestCase.assertNull(mainCompInst);
     }
 
-    protected static void delay(int millis)
-    {
-        try
-        {
-            Thread.sleep(millis);
-        }
-        catch (InterruptedException ie)
-        {
-        }
-    }
-
 }



Mime
View raw message