This is an automated email from the ASF dual-hosted git repository.
timothyjward pushed a commit to branch feature/v1.1
in repository https://gitbox.apache.org/repos/asf/aries-typedevent.git
The following commit(s) were added to refs/heads/feature/v1.1 by this push:
new d7e5bd6 Properly clear data structures when they are empty
d7e5bd6 is described below
commit d7e5bd6a9b4c32a016da5166ce7e2ccf11b1eba2
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 5c58047..1a73d73 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
@@ -337,17 +337,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(new EventSelector(s,
null).getInitial());
+ handlers = wildcardMap;
+ key = new EventSelector(s, null).getInitial();
} 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);
}
}
});