FELIX-3891 avoid deadlock in Felix ServiceRegistry unregister service by proper use of DS component context in test
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1444493 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java b/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
index 4e20e79..0836696 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
@@ -749,7 +749,7 @@
else
{
// Avoid out of memory ...
- m_warnings.add( 1024, "Unexpected errors logged. Please look at previous logs" );
+ m_warnings.set( 1023, "Unexpected errors logged. Please look at previous logs" );
}
}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680_2/Main.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680_2/Main.java
index 273e79c..ecb6cb2 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680_2/Main.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680_2/Main.java
@@ -40,13 +40,14 @@
public class Main implements Runnable
{
+ private static final int LATCH_TIMEOUT = 10000;
private volatile ComponentContext m_ctx;
private volatile AtomicInteger m_counter = new AtomicInteger();
private volatile CountDownLatch m_enabledLatch;
private volatile CountDownLatch m_disabledLatch;
private volatile LogService m_logService;
private ScrService m_scr;
- private final Executor m_exec = Executors.newFixedThreadPool( 50 );
+ private final Executor m_exec = Executors.newFixedThreadPool( 12 );
private volatile BundleContext m_bctx;
volatile ConcurrentHashMap<Class, ServiceRegistration> m_registrations = new ConcurrentHashMap<Class, ServiceRegistration>();
volatile Exception _bindStackTrace;
@@ -169,7 +170,7 @@
_bindStackTrace = trace;
- A a = ( A ) sr.getBundle().getBundleContext().getService( sr );
+ A a = ( A ) m_ctx.locateService( "a", sr );
if ( a == null )
{
throw new IllegalStateException( "bindA: bundleContext.getService returned null" );
@@ -220,7 +221,7 @@
try
{
- if ( !m_enabledLatch.await( 10000, TimeUnit.MILLISECONDS ) )
+ if ( !m_enabledLatch.await( LATCH_TIMEOUT, TimeUnit.MILLISECONDS ) )
{
System.out.println( "Did not get A injected timely ... see logs.txt" );
m_logService.log( LogService.LOG_ERROR, "enableLatch TIMEOUT" );
@@ -236,7 +237,7 @@
registry.unregisterBCDEFGHIJK( m_exec );
try
{
- if ( !m_disabledLatch.await( 10000, TimeUnit.MILLISECONDS ) )
+ if ( !m_disabledLatch.await( LATCH_TIMEOUT, TimeUnit.MILLISECONDS ) )
{
System.out.println( "Could not disable components timely ... see logs.txt" );
m_logService.log( LogService.LOG_ERROR, "disableLatch TIMEOUT" );