This is an automated email from the ASF dual-hosted git repository. amichair pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit 7851356352f1afdf394bde8de0cae562fbc8081e Author: Amichai Rothman <[email protected]> AuthorDate: Fri Jun 5 14:48:34 2026 +0300 ARIES-2234 Fix deadlock between TopologyManager.importService and RemoteServiceAdminCore.removeImportRegistration --- .../aries/rsa/core/RemoteServiceAdminCore.java | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java index 6683f040..7ab8353f 100644 --- a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java +++ b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java @@ -504,23 +504,22 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin { } protected void removeImportRegistration(ImportRegistration iri) { - synchronized (importedServices) { - LOG.debug("Removing importRegistration {}", iri); - - ImportReference importRef = iri.getException() != null ? null : iri.getImportReference(); - if (importRef == null) { - return; + LOG.debug("Removing importRegistration {}", iri); + ImportReference importRef = iri.getException() != null ? null : iri.getImportReference(); + EndpointDescription endpoint = importRef == null ? null : importRef.getImportedEndpoint(); + if (endpoint != null) { + boolean removed; + synchronized (importedServices) { + Collection<ImportRegistration> imRegs = importedServices.get(endpoint); + removed = imRegs != null && imRegs.contains(iri) && imRegs.remove(iri); + if (removed && imRegs.isEmpty()) { + importedServices.remove(endpoint); + } } - - EndpointDescription endpoint = importRef.getImportedEndpoint(); - Collection<ImportRegistration> imRegs = importedServices.get(endpoint); - if (imRegs != null && imRegs.contains(iri)) { - imRegs.remove(iri); + // notify without holding lock to prevent deadlock + if (removed) { eventProducer.notifyRemoval(iri); } - if (imRegs == null || imRegs.isEmpty()) { - importedServices.remove(endpoint); - } } }
