This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/main by this push:
     new 6ba8d90  [KARAF-7231] Remove DESTROYED blueprint containers from 
states map
     new 42d9c8e  Merge pull request #1417 from jbonofre/KARAF-7231
6ba8d90 is described below

commit 6ba8d90a8bb99c6c5bad82cc3fced2e9b5b2be72
Author: Jean-Baptiste Onofré <[email protected]>
AuthorDate: Mon Aug 9 07:05:11 2021 +0200

    [KARAF-7231] Remove DESTROYED blueprint containers from states map
---
 .../bundle/state/blueprint/internal/BlueprintStateService.java     | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/bundle/blueprintstate/src/main/java/org/apache/karaf/bundle/state/blueprint/internal/BlueprintStateService.java
 
b/bundle/blueprintstate/src/main/java/org/apache/karaf/bundle/state/blueprint/internal/BlueprintStateService.java
index 8646d0e..b9bd148 100644
--- 
a/bundle/blueprintstate/src/main/java/org/apache/karaf/bundle/state/blueprint/internal/BlueprintStateService.java
+++ 
b/bundle/blueprintstate/src/main/java/org/apache/karaf/bundle/state/blueprint/internal/BlueprintStateService.java
@@ -103,7 +103,12 @@ public class BlueprintStateService implements 
org.osgi.service.blueprint.contain
             LOG.debug("Blueprint app state changed to " + state + " for bundle 
"
                       + blueprintEvent.getBundle().getBundleId());
         }
-        states.put(blueprintEvent.getBundle().getBundleId(), blueprintEvent);
+        // DESTROYED blueprint containers should be removed from the map to 
avoid memory "leak/high consumption"
+        if (blueprintEvent.getType() == BlueprintEvent.DESTROYED) {
+            states.remove(blueprintEvent.getBundle().getBundleId());
+        } else {
+            states.put(blueprintEvent.getBundle().getBundleId(), 
blueprintEvent);
+        }
     }
 
     @Override

Reply via email to