felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1629402 - in /felix/trunk/eventadmin/impl: ./ src/main/java/org/apache/felix/eventadmin/impl/tasks/
Date Sat, 04 Oct 2014 15:06:44 GMT
Author: cziegeler
Date: Sat Oct  4 15:06:44 2014
New Revision: 1629402

URL: http://svn.apache.org/r1629402
Log:
FELIX-4663 : Potential memory leak in AsyncDeliveryTask

Modified:
    felix/trunk/eventadmin/impl/changelog.txt
    felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/AsyncDeliverTasks.java
    felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/DefaultThreadPool.java
    felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/SyncDeliverTasks.java

Modified: felix/trunk/eventadmin/impl/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/eventadmin/impl/changelog.txt?rev=1629402&r1=1629401&r2=1629402&view=diff
==============================================================================
--- felix/trunk/eventadmin/impl/changelog.txt (original)
+++ felix/trunk/eventadmin/impl/changelog.txt Sat Oct  4 15:06:44 2014
@@ -3,6 +3,7 @@ Changes from 1.4.2 to 1.4.4
 ** Improvement
     * [FELIX-4623] - Add test for thread based ordering
     * [FELIX-4638] - Less locking on event handler timing
+    * [FELIX-4663] - Potential memory leak in AsyncDeliveryTask
 
 
 Changes from 1.4.0 to 1.4.2

Modified: felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/AsyncDeliverTasks.java
URL: http://svn.apache.org/viewvc/felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/AsyncDeliverTasks.java?rev=1629402&r1=1629401&r2=1629402&view=diff
==============================================================================
--- felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/AsyncDeliverTasks.java
(original)
+++ felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/AsyncDeliverTasks.java
Sat Oct  4 15:06:44 2014
@@ -98,7 +98,11 @@ public class AsyncDeliverTasks
                 {
                     // reactivate thread
                     executer.setSyncDeliverTasks(m_deliver_task);
-                    m_pool.executeTask(executer);
+                    if ( !m_pool.executeTask(executer) )
+                    {
+                        // scheduling failed: last resort, call directly
+                        executer.run();
+                    }
                     m_running_threads.put(currentThreadId, executer);
                 }
             }

Modified: felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/DefaultThreadPool.java
URL: http://svn.apache.org/viewvc/felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/DefaultThreadPool.java?rev=1629402&r1=1629401&r2=1629402&view=diff
==============================================================================
--- felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/DefaultThreadPool.java
(original)
+++ felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/DefaultThreadPool.java
Sat Oct  4 15:06:44 2014
@@ -94,7 +94,7 @@ public class DefaultThreadPool
             }
         }
     }
-    
+
     /**
      * Returns current pool size.
      */
@@ -115,19 +115,20 @@ public class DefaultThreadPool
     /**
      * Execute the task in a free thread or create a new one.
      * @param task The task to execute
+     * @return {@code true} if the task execution could be scheduled, {@code false} otherwise.
      */
-    public void executeTask(final Runnable task)
-    {
+    public boolean executeTask(final Runnable task) {
         try
         {
             this.executor.submit(task);
+            return true;
         }
         catch (final Throwable t)
         {
             LogWrapper.getLogger().log(
                     LogWrapper.LOG_WARNING,
                     "Exception: " + t, t);
-            // ignore this
+            return false;
         }
     }
 }

Modified: felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/SyncDeliverTasks.java
URL: http://svn.apache.org/viewvc/felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/SyncDeliverTasks.java?rev=1629402&r1=1629401&r2=1629402&view=diff
==============================================================================
--- felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/SyncDeliverTasks.java
(original)
+++ felix/trunk/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/SyncDeliverTasks.java
Sat Oct  4 15:06:44 2014
@@ -92,7 +92,7 @@ public class SyncDeliverTasks
 
         final Iterator<EventHandlerProxy> i = tasks.iterator();
         final BlacklistLatch handlerLatch = new BlacklistLatch(tasks.size(), this.timeout/2);
-        
+
         while ( i.hasNext() )
         {
             final EventHandlerProxy task = i.next();
@@ -111,14 +111,18 @@ public class SyncDeliverTasks
                 }
                 else
                 {
-                	
+
                 	handlerLatch.addToBlacklistCheck(handlerTask);
-                    this.pool.executeTask(handlerTask);
+                    if ( !this.pool.executeTask(handlerTask) )
+                    {
+                        // scheduling failed: last resort, call directly
+                        handlerTask.run();
+                    }
                 }
-               
+
 //            }
         }
         handlerLatch.awaitAndBlacklistCheck();
-        
+
     }
 }



Mime
View raw message