This is an automated email from the ASF dual-hosted git repository. timothyjward pushed a commit to branch fix/bugs in repository https://gitbox.apache.org/repos/asf/aries-typedevent.git
commit 206a419c4f2713c54eba0b35d9e1613f237b296c Author: Tim Ward <[email protected]> AuthorDate: Fri Sep 15 17:10:41 2023 +0100 Properly clear data structures when they are empty Signed-off-by: Tim Ward <[email protected]> --- .../aries/typedevent/bus/impl/TypedEventBusImpl.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/org.apache.aries.typedevent.bus/src/main/java/org/apache/aries/typedevent/bus/impl/TypedEventBusImpl.java b/org.apache.aries.typedevent.bus/src/main/java/org/apache/aries/typedevent/bus/impl/TypedEventBusImpl.java index 9c4057e..5ce2ef8 100644 --- a/org.apache.aries.typedevent.bus/src/main/java/org/apache/aries/typedevent/bus/impl/TypedEventBusImpl.java +++ b/org.apache.aries.typedevent.bus/src/main/java/org/apache/aries/typedevent/bus/impl/TypedEventBusImpl.java @@ -314,17 +314,20 @@ public class TypedEventBusImpl implements TypedEventBus { idMap.remove(serviceId); if (consumed != null) { consumed.forEach(s -> { - Map<T, ?> handlers; + Map<String, Map<T, U>> handlers; + String key; if(isWildcard(s)) { - handlers = wildcardMap.get(s.length() == 1 ? "" : s.substring(0, s.length() - 2)); + handlers = wildcardMap; + key = s.length() == 1 ? "" : s.substring(0, s.length() - 2); } else { - handlers = map.get(s); + handlers = map; + key = s; } - - if (handlers != null) { - handlers.remove(handler); - if (handlers.isEmpty()) { - map.remove(s); + Map<T,?> subMap = handlers.get(key); + if (subMap != null) { + subMap.remove(handler); + if (subMap.isEmpty()) { + map.remove(key); } } });
