felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1771397 - /felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
Date Fri, 25 Nov 2016 22:09:15 GMT
Author: pderop
Date: Fri Nov 25 22:09:15 2016
New Revision: 1771397

URL: http://svn.apache.org/viewvc?rev=1771397&view=rev
Log:
FELIX-5428: reverted previous patch, because actually the handleRemoved method must not remove
the dependency from the m_dependencyEvents
map, since it may break the state machine if the SM is currently running.
So, a better solution is to add a cleanup() method which is called when we enter into the
INACTIVE state.

Modified:
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java?rev=1771397&r1=1771396&r2=1771397&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
Fri Nov 25 22:09:15 2016
@@ -1050,11 +1050,16 @@ public class ComponentImpl implements Co
             stopDependencies();
             destroyComponent();
             notifyListeners(newState);
+            cleanup();
             return true;
         }
         return false;
     }
     
+	private void cleanup() {
+		m_dependencyEvents.values().forEach(eventList -> eventList.clear());
+	}
+
 	private void invokeStart() {
         invoke(m_callbackStart);
         m_startCalled = true;
@@ -1162,17 +1167,12 @@ public class ComponentImpl implements Co
      */
     private void handleRemoved(DependencyContext dc, Event e) {
     	try {
-    		Set<Event> dependencyEvents = m_dependencyEvents.get(dc);
     		if (! m_isStarted) {
-    			if (dependencyEvents != null) {
-    				// Cleanup the dependency events, in case the component will be restarted later.
-    				// (else when the component is restarted, the removed dependencies would then be
re-injected !)
-    				dependencyEvents.remove(e);
-    			}
     			return;
     		}
     		
     		// Check if the dependency is still available.
+    		Set<Event> dependencyEvents = m_dependencyEvents.get(dc);
     		int size = dependencyEvents.size();
     		if (dependencyEvents.contains(e)) {
     			size--; // the dependency is currently registered and is about to be removed.



Mime
View raw message