This is an automated email from the ASF dual-hosted git repository. amichai pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit 6b90f390697093b3e9221f4a3013df4b2160ba7e Author: Amichai Rothman <[email protected]> AuthorDate: Tue Mar 17 00:57:16 2026 +0200 Fix ConfigDiscovery not sending MODIFIED_ENDMATCH events --- .../aries/rsa/discovery/config/ConfigDiscovery.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/discovery/config/src/main/java/org/apache/aries/rsa/discovery/config/ConfigDiscovery.java b/discovery/config/src/main/java/org/apache/aries/rsa/discovery/config/ConfigDiscovery.java index d7d35b5f..052dd0f0 100644 --- a/discovery/config/src/main/java/org/apache/aries/rsa/discovery/config/ConfigDiscovery.java +++ b/discovery/config/src/main/java/org/apache/aries/rsa/discovery/config/ConfigDiscovery.java @@ -82,13 +82,24 @@ class ConfigDiscovery implements ManagedServiceFactory { private void addDeclaredRemoteService(String pid, Dictionary<String, ?> config) { EndpointDescription endpoint = new EndpointDescription(PropertyValidator.validate(config)); - List<Map.Entry<Filter, EndpointEventListener>> matched; - boolean isNew; + EndpointDescription old; + Set<Map.Entry<Filter, EndpointEventListener>> oldMatches, newMatches; synchronized (this) { - isNew = endpoints.put(pid, endpoint) == null; - matched = findMatches(endpoint); + old = endpoints.put(pid, endpoint); + oldMatches = old == null ? null : new HashSet<>(findMatches(old)); + newMatches = new HashSet<>(findMatches(endpoint)); + } + List<Map.Entry<Filter, EndpointEventListener>> added = new ArrayList<>(newMatches); + if (old != null) { + added.removeAll(oldMatches); + List<Map.Entry<Filter, EndpointEventListener>> endmatch = new ArrayList<>(oldMatches); + endmatch.removeAll(newMatches); + List<Map.Entry<Filter, EndpointEventListener>> modified = new ArrayList<>(oldMatches); + modified.removeAll(endmatch); + triggerEvent(new EndpointEvent(EndpointEvent.MODIFIED, endpoint), modified); + triggerEvent(new EndpointEvent(EndpointEvent.MODIFIED_ENDMATCH, old), endmatch); } - triggerEvent(new EndpointEvent(isNew ? EndpointEvent.ADDED : EndpointEvent.MODIFIED, endpoint), matched); + triggerEvent(new EndpointEvent(EndpointEvent.ADDED, endpoint), added); } private void removeServiceDeclaredInConfig(String pid) {
