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 2012/10/25 19:59:56 UTC
svn commit: r1402234 - in
/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl: Activator.java
ComponentActorThread.java
Author: djencks
Date: Thu Oct 25 17:59:55 2012
New Revision: 1402234
URL: http://svn.apache.org/viewvc?rev=1402234&view=rev
Log:
FELIX-3727 wait for actor to finish, and also avoid NPE
Modified:
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentActorThread.java
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java?rev=1402234&r1=1402233&r2=1402234&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java Thu Oct 25 17:59:55 2012
@@ -375,7 +375,8 @@ public class Activator implements Bundle
{
if ( m_configuration.getLogLevel() >= level )
{
- Object logger = ( m_logService != null ) ? m_logService.getService() : null;
+ ServiceTracker t = m_logService;
+ Object logger = ( t != null ) ? t.getService() : null;
if ( logger == null )
{
// output depending on level
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentActorThread.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentActorThread.java?rev=1402234&r1=1402233&r2=1402234&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentActorThread.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentActorThread.java Thu Oct 25 17:59:55 2012
@@ -84,16 +84,16 @@ class ComponentActorThread implements Ru
task = ( Runnable ) tasks.removeFirst();
}
- // return if the task is this thread itself
- if ( task == TERMINATION_TASK )
- {
- Activator.log( LogService.LOG_DEBUG, null, "Shutting down ComponentActorThread", null );
- return;
- }
-
- // otherwise execute the task, log any issues
try
{
+ // return if the task is this thread itself
+ if ( task == TERMINATION_TASK )
+ {
+ Activator.log( LogService.LOG_DEBUG, null, "Shutting down ComponentActorThread", null );
+ return;
+ }
+
+ // otherwise execute the task, log any issues
Activator.log( LogService.LOG_DEBUG, null, "Running task: " + task, null );
task.run();
}
@@ -101,6 +101,13 @@ class ComponentActorThread implements Ru
{
Activator.log( LogService.LOG_ERROR, null, "Unexpected problem executing task " + task, t );
}
+ finally
+ {
+ synchronized ( tasks )
+ {
+ tasks.notifyAll();
+ }
+ }
}
}
@@ -110,6 +117,20 @@ class ComponentActorThread implements Ru
void terminate()
{
schedule( TERMINATION_TASK );
+ synchronized ( tasks )
+ {
+ while ( !tasks.isEmpty() )
+ {
+ try
+ {
+ tasks.wait();
+ }
+ catch ( InterruptedException e )
+ {
+ Activator.log( LogService.LOG_ERROR, null, "Interrupted exception waiting for queue to empty", e );
+ }
+ }
+ }
}