You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by am...@apache.org on 2026/06/17 09:47:43 UTC
(aries-rsa) branch master updated (6fecd15e -> 8ac2c1fa)
This is an automated email from the ASF dual-hosted git repository.
amichair pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
from 6fecd15e Remove unused imports
new 78513563 ARIES-2234 Fix deadlock between TopologyManager.importService and RemoteServiceAdminCore.removeImportRegistration
new 8ac2c1fa Standardize Import/Export Registration/Reference variable names
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../aries/rsa/core/ClientServiceFactory.java | 4 +-
.../org/apache/aries/rsa/core/CloseHandler.java | 4 +-
.../aries/rsa/core/ImportRegistrationImpl.java | 22 ++--
.../aries/rsa/core/RemoteServiceAdminCore.java | 133 ++++++++++-----------
.../aries/rsa/core/RemoteServiceAdminInstance.java | 26 ++--
.../aries/rsa/core/event/EventAdminSender.java | 8 +-
.../apache/aries/rsa/core/event/EventProducer.java | 44 +++----
.../aries/rsa/core/ClientServiceFactoryTest.java | 4 +-
.../aries/rsa/core/ImportRegistrationImplTest.java | 64 +++++-----
.../aries/rsa/core/RemoteServiceAdminCoreTest.java | 6 +-
.../aries/rsa/core/event/EventAdminSenderTest.java | 36 +++---
.../aries/rsa/core/event/EventProducerTest.java | 6 +-
.../exporter/ServiceExportsRepository.java | 24 ++--
.../exporter/TopologyManagerExport.java | 10 +-
.../importer/TopologyManagerImport.java | 36 +++---
.../exporter/TopologyManagerExportTest.java | 20 ++--
.../importer/TopologyManagerImportTest.java | 6 +-
17 files changed, 226 insertions(+), 227 deletions(-)
(aries-rsa) 01/02: ARIES-2234 Fix deadlock between TopologyManager.importService and RemoteServiceAdminCore.removeImportRegistration
Posted by am...@apache.org.
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 <am...@apache.org>
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);
- }
}
}
(aries-rsa) 02/02: Standardize Import/Export Registration/Reference variable names
Posted by am...@apache.org.
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 8ac2c1fa688bed53891b7f48d228471f6916a3b8
Author: Amichai Rothman <am...@apache.org>
AuthorDate: Mon Jun 8 20:13:12 2026 +0300
Standardize Import/Export Registration/Reference variable names
---
.../aries/rsa/core/ClientServiceFactory.java | 4 +-
.../org/apache/aries/rsa/core/CloseHandler.java | 4 +-
.../aries/rsa/core/ImportRegistrationImpl.java | 22 ++--
.../aries/rsa/core/RemoteServiceAdminCore.java | 118 ++++++++++-----------
.../aries/rsa/core/RemoteServiceAdminInstance.java | 26 ++---
.../aries/rsa/core/event/EventAdminSender.java | 8 +-
.../apache/aries/rsa/core/event/EventProducer.java | 44 ++++----
.../aries/rsa/core/ClientServiceFactoryTest.java | 4 +-
.../aries/rsa/core/ImportRegistrationImplTest.java | 64 +++++------
.../aries/rsa/core/RemoteServiceAdminCoreTest.java | 6 +-
.../aries/rsa/core/event/EventAdminSenderTest.java | 36 +++----
.../aries/rsa/core/event/EventProducerTest.java | 6 +-
.../exporter/ServiceExportsRepository.java | 24 ++---
.../exporter/TopologyManagerExport.java | 10 +-
.../importer/TopologyManagerImport.java | 36 +++----
.../exporter/TopologyManagerExportTest.java | 20 ++--
.../importer/TopologyManagerImportTest.java | 6 +-
17 files changed, 219 insertions(+), 219 deletions(-)
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/ClientServiceFactory.java b/rsa/src/main/java/org/apache/aries/rsa/core/ClientServiceFactory.java
index 869a1dfc..dd7c9ece 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/ClientServiceFactory.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/ClientServiceFactory.java
@@ -51,10 +51,10 @@ public class ClientServiceFactory implements ServiceFactory {
private Map<Object, ImportedService> services = new HashMap<>();
public ClientServiceFactory(EndpointDescription endpoint,
- DistributionProvider handler, ImportRegistrationImpl ir) {
+ DistributionProvider handler, ImportRegistrationImpl ireg) {
this.endpoint = endpoint;
this.handler = handler;
- this.importRegistration = ir;
+ this.importRegistration = ireg;
}
public Object getService(final Bundle requestingBundle, final ServiceRegistration sreg) {
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/CloseHandler.java b/rsa/src/main/java/org/apache/aries/rsa/core/CloseHandler.java
index be310890..1067820f 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/CloseHandler.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/CloseHandler.java
@@ -22,6 +22,6 @@ import org.osgi.service.remoteserviceadmin.ExportRegistration;
import org.osgi.service.remoteserviceadmin.ImportRegistration;
public interface CloseHandler {
- public void onClose(ExportRegistration exportReg);
- public void onClose(ImportRegistration importReg);
+ public void onClose(ExportRegistration ereg);
+ public void onClose(ImportRegistration ireg);
}
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/ImportRegistrationImpl.java b/rsa/src/main/java/org/apache/aries/rsa/core/ImportRegistrationImpl.java
index 589e37f0..4cc8701e 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/ImportRegistrationImpl.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/ImportRegistrationImpl.java
@@ -67,21 +67,21 @@ public class ImportRegistrationImpl implements ImportRegistration, ImportReferen
/**
* Add a linked ImportRegistration instance to the shared data.
*
- * @param ir the instance to add
+ * @param ireg the instance to add
*/
- private synchronized void addInstance(ImportRegistrationImpl ir) {
- instances.add(ir);
+ private synchronized void addInstance(ImportRegistrationImpl ireg) {
+ instances.add(ireg);
}
/**
* Remove a linked ImportRegistration from the shared data.
*
- * @param ir the instance to remove
+ * @param ireg the instance to remove
*/
- private void removeInstance(ImportRegistrationImpl ir) {
+ private void removeInstance(ImportRegistrationImpl ireg) {
// close the underlying service only once on the last remove (not before or after)
synchronized (this) {
- boolean removed = instances.remove(ir);
+ boolean removed = instances.remove(ireg);
if (!removed || !instances.isEmpty()) {
return;
}
@@ -109,8 +109,8 @@ public class ImportRegistrationImpl implements ImportRegistration, ImportReferen
copy = new ArrayList<>(instances);
}
LOG.info("closing all linked ImportRegistrations");
- for (ImportRegistrationImpl ir : copy) {
- ir.close();
+ for (ImportRegistrationImpl ireg : copy) {
+ ireg.close();
}
}
}
@@ -145,10 +145,10 @@ public class ImportRegistrationImpl implements ImportRegistration, ImportReferen
* <p>
* The {@link #close} method must eventually be invoked on this instance.
*
- * @param ir the import registration that this instance is linked to
+ * @param ireg the import registration that this instance is linked to
*/
- public ImportRegistrationImpl(ImportRegistration ir) {
- shared = ((ImportRegistrationImpl)ir).shared;
+ public ImportRegistrationImpl(ImportRegistration ireg) {
+ shared = ((ImportRegistrationImpl)ireg).shared;
shared.addInstance(this);
}
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 7ab8353f..ac9ab942 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
@@ -82,13 +82,13 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
this.eventProducer = eventProducer;
this.provider = provider;
this.closeHandler = new CloseHandler() {
- public void onClose(ExportRegistration reg) {
- removeExportRegistration(reg);
- if (reg.getException() != null) {
+ public void onClose(ExportRegistration ereg) {
+ removeExportRegistration(ereg);
+ if (ereg.getException() != null) {
return; // there is no reference to close, and an exception if we try getting it
}
- ExportReference ref = reg.getExportReference();
- ServiceReference<?> sref = ref == null ? null : ref.getExportedService();
+ ExportReference eref = ereg.getExportReference();
+ ServiceReference<?> sref = eref == null ? null : eref.getExportedService();
Bundle bundle = sref == null ? null : sref.getBundle();
BundleContext context = bundle == null ? null : bundle.getBundleContext();
// the bundle/context may already be closed, e.g. when called from
@@ -100,8 +100,8 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
}
}
- public void onClose(ImportRegistration importReg) {
- removeImportRegistration(importReg);
+ public void onClose(ImportRegistration ireg) {
+ removeImportRegistration(ireg);
}
};
}
@@ -146,12 +146,12 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
return regs;
}
- private void store(Map<String, Object> key, List<ExportRegistration> regs) {
+ private void store(Map<String, Object> key, List<ExportRegistration> eregs) {
// enlist initial export registrations in global list of exportRegistrations
synchronized (exportedServices) {
- exportedServices.put(key, new ArrayList<>(regs));
+ exportedServices.put(key, new ArrayList<>(eregs));
}
- eventProducer.publishNotification(regs);
+ eventProducer.publishNotification(eregs);
}
private void unlock(Map<String, Object> key) {
@@ -164,13 +164,13 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
private List<ExportRegistration> getExistingOrLock(Map<String, Object> key, List<String> interfaces) {
synchronized (exportedServices) {
// check if it is already exported...
- Collection<ExportRegistration> regs = exportedServices.get(key);
+ Collection<ExportRegistration> eregs = exportedServices.get(key);
// if the export is already in progress, wait for it to be complete
- while (regs == EXPORT_IN_PROGRESS) {
+ while (eregs == EXPORT_IN_PROGRESS) {
try {
exportedServices.wait();
- regs = exportedServices.get(key);
+ eregs = exportedServices.get(key);
} catch (InterruptedException ie) {
LOG.debug("interrupted while waiting for export in progress");
return Collections.emptyList();
@@ -178,9 +178,9 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
}
// if the export is complete, return a copy of existing export
- if (regs != null) {
+ if (eregs != null) {
LOG.debug("already exported this service. Returning existing registrations {} ", interfaces);
- return copyExportRegistration(regs);
+ return copyExportRegistration(eregs);
}
// mark export as being in progress
@@ -211,7 +211,7 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
if (serviceObject == null) {
throw new IllegalStateException("service object is null (service was unregistered?)");
}
- ExportRegistration reg = null;
+ ExportRegistration ereg = null;
try {
final Class<?>[] interfaces = getInterfaces(serviceObject, interfaceNames);
final Map<String, Object> eprops = createEndpointProps(serviceProperties, configTypes, interfaces);
@@ -220,12 +220,12 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
(PrivilegedAction<Endpoint>) () -> provider.exportService(
serviceObject, serviceContext, eprops, interfaces));
if (endpoint != null) {
- reg = new ExportRegistrationImpl(serviceReference, endpoint, closeHandler, eventProducer);
+ ereg = new ExportRegistrationImpl(serviceReference, endpoint, closeHandler, eventProducer);
}
- return reg;
+ return ereg;
} finally {
// if anything went wrong, don't leak the service reference
- if (reg == null) {
+ if (ereg == null) {
serviceContext.ungetService(serviceReference);
}
}
@@ -347,26 +347,26 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
return converted;
}
- private List<ExportRegistration> copyExportRegistration(Collection<ExportRegistration> regs) {
+ private List<ExportRegistration> copyExportRegistration(Collection<ExportRegistration> eregs) {
Set<EndpointDescription> copiedEndpoints = new HashSet<>();
// create a new list with copies of the exportRegistrations
- List<ExportRegistration> copy = new ArrayList<>(regs.size());
- for (ExportRegistration reg : regs) {
- ExportRegistrationImpl exportRegistrationImpl = (ExportRegistrationImpl) reg;
- ExportReference ref = reg.getException() != null ? null : reg.getExportReference();
- EndpointDescription endpoint = ref == null ? null : ref.getExportedEndpoint();
+ List<ExportRegistration> copy = new ArrayList<>(eregs.size());
+ for (ExportRegistration ereg : eregs) {
+ ExportRegistrationImpl exportRegistrationImpl = (ExportRegistrationImpl) ereg;
+ ExportReference eref = ereg.getException() != null ? null : ereg.getExportReference();
+ EndpointDescription endpoint = eref == null ? null : eref.getExportedEndpoint();
// create one copy for each distinct endpoint description
if (endpoint != null && copiedEndpoints.add(endpoint)) {
copy.add(new ExportRegistrationImpl(exportRegistrationImpl));
// also increase service reference count
- ServiceReference<?> sref = ref.getExportedService();
+ ServiceReference<?> sref = eref.getExportedService();
BundleContext serviceContext = getBundleContext(sref);
serviceContext.getService(sref); // unget it when export is closed
}
}
- regs.addAll(copy);
+ eregs.addAll(copy);
eventProducer.publishNotification(copy);
return copy;
@@ -405,14 +405,14 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
LOG.debug("importService() Endpoint: {}", endpoint.getProperties());
synchronized (importedServices) {
- Collection<ImportRegistration> imRegs = importedServices.get(endpoint);
- if (imRegs != null && !imRegs.isEmpty()) {
+ Collection<ImportRegistration> iregs = importedServices.get(endpoint);
+ if (iregs != null && !iregs.isEmpty()) {
LOG.debug("creating copy of existing import registrations");
- ImportRegistration irParent = imRegs.iterator().next();
- ImportRegistration ir = new ImportRegistrationImpl(irParent);
- imRegs.add(ir);
- eventProducer.publishNotification(ir);
- return ir;
+ ImportRegistration iregExisting = iregs.iterator().next();
+ ImportRegistration ireg = new ImportRegistrationImpl(iregExisting);
+ iregs.add(ireg);
+ eventProducer.publishNotification(ireg);
+ return ireg;
}
if (matchConfigTypes(endpoint.getConfigurationTypes(), false).isEmpty()) {
@@ -432,14 +432,14 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
LOG.info("Importing service {} with interfaces {} using handler {}.",
endpoint.getId(), endpoint.getInterfaces(), provider.getClass());
- ImportRegistrationImpl imReg = exposeServiceFactory(matchingInterfaces.toArray(new String[0]), endpoint, provider);
- if (imRegs == null) {
- imRegs = new ArrayList<>();
- importedServices.put(endpoint, imRegs);
+ ImportRegistrationImpl ireg = exposeServiceFactory(matchingInterfaces.toArray(new String[0]), endpoint, provider);
+ if (iregs == null) {
+ iregs = new ArrayList<>();
+ importedServices.put(endpoint, iregs);
}
- imRegs.add(imReg);
- eventProducer.publishNotification(imReg);
- return imReg;
+ iregs.add(ireg);
+ eventProducer.publishNotification(ireg);
+ return ireg;
}
}
@@ -456,23 +456,23 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
protected ImportRegistrationImpl exposeServiceFactory(String[] interfaceNames,
EndpointDescription endpoint,
DistributionProvider handler) {
- ImportRegistrationImpl imReg = new ImportRegistrationImpl(endpoint, closeHandler, eventProducer);
+ ImportRegistrationImpl ireg = new ImportRegistrationImpl(endpoint, closeHandler, eventProducer);
try {
Dictionary<String, Object> serviceProps = new Hashtable<>(endpoint.getProperties());
- ClientServiceFactory csf = new ClientServiceFactory(endpoint, handler, imReg);
+ ClientServiceFactory csf = new ClientServiceFactory(endpoint, handler, ireg);
// Export the factory using the api context as it has very few imports.
// If the bundle publishing the factory does not import the service interface
// package then the factory is visible for all consumers which we want.
ServiceRegistration<?> csfReg = apictx.registerService(interfaceNames, csf, serviceProps);
- imReg.init(csf, csfReg);
+ ireg.init(csf, csfReg);
} catch (Exception ex) {
// Only logging at debug level as this might be written to the log at the TopologyManager
LOG.debug("Can not proxy service with interfaces {}: {}",
Arrays.toString(interfaceNames), ex.getMessage(), ex);
- imReg.init(ex);
+ ireg.init(ex);
}
- return imReg;
+ return ireg;
}
/**
@@ -480,17 +480,17 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
* This is called from the ExportRegistration itself when it is closed (so should
* not attempt to close it again here).
*
- * @param eri the export registration to remove
+ * @param ereg the export registration to remove
*/
- protected void removeExportRegistration(ExportRegistration eri) {
+ protected void removeExportRegistration(ExportRegistration ereg) {
synchronized (exportedServices) {
for (Iterator<Collection<ExportRegistration>> it = exportedServices.values().iterator(); it.hasNext();) {
Collection<ExportRegistration> value = it.next();
for (Iterator<ExportRegistration> it2 = value.iterator(); it2.hasNext();) {
ExportRegistration er = it2.next();
- if (er.equals(eri)) {
- if (eri.getException() == null && eri.getExportReference() != null) {
- eventProducer.notifyRemoval(eri.getExportReference());
+ if (er.equals(ereg)) {
+ if (ereg.getException() == null && ereg.getExportReference() != null) {
+ eventProducer.notifyRemoval(ereg.getExportReference());
}
it2.remove();
if (value.isEmpty()) {
@@ -503,22 +503,22 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
}
}
- protected void removeImportRegistration(ImportRegistration iri) {
- LOG.debug("Removing importRegistration {}", iri);
- ImportReference importRef = iri.getException() != null ? null : iri.getImportReference();
- EndpointDescription endpoint = importRef == null ? null : importRef.getImportedEndpoint();
+ protected void removeImportRegistration(ImportRegistration ireg) {
+ LOG.debug("Removing importRegistration {}", ireg);
+ ImportReference iref = ireg.getException() != null ? null : ireg.getImportReference();
+ EndpointDescription endpoint = iref == null ? null : iref.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()) {
+ Collection<ImportRegistration> iregs = importedServices.get(endpoint);
+ removed = iregs != null && iregs.contains(ireg) && iregs.remove(ireg);
+ if (removed && iregs.isEmpty()) {
importedServices.remove(endpoint);
}
}
// notify without holding lock to prevent deadlock
if (removed) {
- eventProducer.notifyRemoval(iri);
+ eventProducer.notifyRemoval(ireg);
}
}
}
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminInstance.java b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminInstance.java
index c7059483..135dce54 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminInstance.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminInstance.java
@@ -58,11 +58,11 @@ public class RemoteServiceAdminInstance implements RemoteServiceAdmin, CloseHand
@Override
public List<ExportRegistration> exportService(final ServiceReference ref, final Map properties) {
- List<ExportRegistration> regs = rsaCore.exportService(ref, properties);
+ List<ExportRegistration> ereg = rsaCore.exportService(ref, properties);
// we need to keep track of our open registrations, and be notified when they are closed
- regs.forEach(reg -> ((ExportRegistrationImpl)reg).addCloseHandler(this));
- exportRegistrations.addAll(regs);
- return regs;
+ ereg.forEach(reg -> ((ExportRegistrationImpl)reg).addCloseHandler(this));
+ exportRegistrations.addAll(ereg);
+ return ereg;
}
@Override
@@ -81,14 +81,14 @@ public class RemoteServiceAdminInstance implements RemoteServiceAdmin, CloseHand
public ImportRegistration importService(final EndpointDescription endpoint) {
String frameworkUUID = context.getProperty(Constants.FRAMEWORK_UUID);
checkPermission(new EndpointPermission(endpoint, frameworkUUID, EndpointPermission.IMPORT));
- ImportRegistration reg = AccessController.doPrivileged((PrivilegedAction<ImportRegistration>)
+ ImportRegistration ireg = AccessController.doPrivileged((PrivilegedAction<ImportRegistration>)
() -> rsaCore.importService(endpoint));
- if (reg != null) {
+ if (ireg != null) {
// we need to keep track of our open registrations, and be notified when they are closed
- ((ImportRegistrationImpl)reg).addCloseHandler(this);
- importRegistrations.add(reg);
+ ((ImportRegistrationImpl)ireg).addCloseHandler(this);
+ importRegistrations.add(ireg);
}
- return reg;
+ return ireg;
}
/**
@@ -107,12 +107,12 @@ public class RemoteServiceAdminInstance implements RemoteServiceAdmin, CloseHand
}
@Override
- public void onClose(ExportRegistration reg) {
- exportRegistrations.remove(reg); // registration was closed, no need to track it anymore
+ public void onClose(ExportRegistration ereg) {
+ exportRegistrations.remove(ereg); // registration was closed, no need to track it anymore
}
@Override
- public void onClose(ImportRegistration reg) {
- importRegistrations.remove(reg); // registration was closed, no need to track it anymore
+ public void onClose(ImportRegistration ireg) {
+ importRegistrations.remove(ireg); // registration was closed, no need to track it anymore
}
}
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/event/EventAdminSender.java b/rsa/src/main/java/org/apache/aries/rsa/core/event/EventAdminSender.java
index 63fcd890..484c1024 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/event/EventAdminSender.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/event/EventAdminSender.java
@@ -130,10 +130,10 @@ public class EventAdminSender {
}
// endpoint properties
- ImportReference importReference = rsae.getImportReference();
- ExportReference exportReference = rsae.getExportReference();
- EndpointDescription endpoint = importReference == null ? null : importReference.getImportedEndpoint();
- endpoint = endpoint == null && exportReference != null ? exportReference.getExportedEndpoint() : endpoint;
+ ImportReference iref = rsae.getImportReference();
+ ExportReference eref = rsae.getExportReference();
+ EndpointDescription endpoint = iref == null ? null : iref.getImportedEndpoint();
+ endpoint = endpoint == null && eref != null ? eref.getExportedEndpoint() : endpoint;
if (endpoint != null) {
putIfNotNull(props, "endpoint.service.id", endpoint.getServiceId());
putIfNotNull(props, "endpoint.framework.uuid", endpoint.getFrameworkUUID());
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/event/EventProducer.java b/rsa/src/main/java/org/apache/aries/rsa/core/event/EventProducer.java
index 307c373a..494126c9 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/event/EventProducer.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/event/EventProducer.java
@@ -44,47 +44,47 @@ public class EventProducer {
eventAdminSender = new EventAdminSender(bc);
}
- public void publishNotification(List<ExportRegistration> erl) {
- for (ExportRegistration exportRegistration : erl) {
+ public void publishNotification(List<ExportRegistration> ereg) {
+ for (ExportRegistration exportRegistration : ereg) {
publishNotification(exportRegistration);
}
}
- protected void publishNotification(ExportRegistration er) {
- if (er.getException() == null) {
- notify(RemoteServiceAdminEvent.EXPORT_REGISTRATION, er.getExportReference(), null);
+ protected void publishNotification(ExportRegistration ereg) {
+ if (ereg.getException() == null) {
+ notify(RemoteServiceAdminEvent.EXPORT_REGISTRATION, ereg.getExportReference(), null);
} else {
- notify(RemoteServiceAdminEvent.EXPORT_ERROR, (ExportReference) null, er.getException());
+ notify(RemoteServiceAdminEvent.EXPORT_ERROR, (ExportReference) null, ereg.getException());
}
}
- public void publishNotification(ImportRegistration ir) {
- if (ir.getException() == null) {
- notify(RemoteServiceAdminEvent.IMPORT_REGISTRATION, ir.getImportReference(), null);
+ public void publishNotification(ImportRegistration ireg) {
+ if (ireg.getException() == null) {
+ notify(RemoteServiceAdminEvent.IMPORT_REGISTRATION, ireg.getImportReference(), null);
} else {
- notify(RemoteServiceAdminEvent.IMPORT_ERROR, (ImportReference) null, ir.getException());
+ notify(RemoteServiceAdminEvent.IMPORT_ERROR, (ImportReference) null, ireg.getException());
}
}
- public void notifyRemoval(ExportReference er) {
- notify(RemoteServiceAdminEvent.EXPORT_UNREGISTRATION, er, null);
+ public void notifyRemoval(ExportReference eref) {
+ notify(RemoteServiceAdminEvent.EXPORT_UNREGISTRATION, eref, null);
}
- public void notifyRemoval(ImportRegistration ir) {
- notify(RemoteServiceAdminEvent.IMPORT_UNREGISTRATION, ir.getImportReference(), null);
+ public void notifyRemoval(ImportRegistration ireg) {
+ notify(RemoteServiceAdminEvent.IMPORT_UNREGISTRATION, ireg.getImportReference(), null);
}
- private void notify(int type, ExportReference er, Throwable ex) {
+ private void notify(int type, ExportReference eref, Throwable ex) {
try {
- RemoteServiceAdminEvent event = new RemoteServiceAdminEvent(type, bctx.getBundle(), er, ex);
+ RemoteServiceAdminEvent event = new RemoteServiceAdminEvent(type, bctx.getBundle(), eref, ex);
notifyListeners(event);
} catch (IllegalStateException ise) {
LOG.debug("can't send notifications since bundle context is no longer valid");
}
}
- private void notify(int type, ImportReference ir, Throwable ex) {
+ private void notify(int type, ImportReference iref, Throwable ex) {
try {
- RemoteServiceAdminEvent event = new RemoteServiceAdminEvent(type, bctx.getBundle(), ir, ex);
+ RemoteServiceAdminEvent event = new RemoteServiceAdminEvent(type, bctx.getBundle(), iref, ex);
notifyListeners(event);
} catch (IllegalStateException ise) {
LOG.debug("can't send notifications since bundle context is no longer valid");
@@ -121,11 +121,11 @@ public class EventProducer {
eventAdminSender.send(rsae);
}
- public void notifyUpdate(ExportReference exportRef) {
- notify(RemoteServiceAdminEvent.EXPORT_UPDATE, exportRef, null);
+ public void notifyUpdate(ExportReference eref) {
+ notify(RemoteServiceAdminEvent.EXPORT_UPDATE, eref, null);
}
- public void notifyUpdate(ImportRegistration importReg) {
- notify(RemoteServiceAdminEvent.IMPORT_UPDATE, importReg.getImportReference(), importReg.getException());
+ public void notifyUpdate(ImportRegistration ireg) {
+ notify(RemoteServiceAdminEvent.IMPORT_UPDATE, ireg.getImportReference(), ireg.getException());
}
}
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java
index 51936261..c1b5cd78 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java
@@ -46,7 +46,7 @@ public class ClientServiceFactoryTest {
IMocksControl control = EasyMock.createControl();
EndpointDescription endpoint = createTestEndpointDesc();
- ImportRegistrationImpl iri = new ImportRegistrationImpl(endpoint, null, null);
+ ImportRegistrationImpl ireg = new ImportRegistrationImpl(endpoint, null, null);
BundleContext consumerContext = control.createMock(BundleContext.class);
Bundle consumerBundle = control.createMock(Bundle.class);
@@ -59,7 +59,7 @@ public class ClientServiceFactoryTest {
DistributionProvider handler = mockDistributionProvider(myTestProxyObject);
control.replay();
- ClientServiceFactory csf = new ClientServiceFactory(endpoint, handler, iri);
+ ClientServiceFactory csf = new ClientServiceFactory(endpoint, handler, ireg);
assertSame(myTestProxyObject, csf.getService(consumerBundle, sreg));
}
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/ImportRegistrationImplTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/ImportRegistrationImplTest.java
index aa20a929..35b13f75 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/ImportRegistrationImplTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/ImportRegistrationImplTest.java
@@ -35,12 +35,12 @@ public class ImportRegistrationImplTest {
Exception e = c.createMock(Exception.class);
c.replay();
- ImportRegistrationImpl i = new ImportRegistrationImpl(null, null, null);
- i.init(e);
+ ImportRegistrationImpl ireg = new ImportRegistrationImpl(null, null, null);
+ ireg.init(e);
- assertEquals(e, i.getException());
- assertNull(i.getImportedEndpoint());
- assertNull(i.getImportedService());
+ assertEquals(e, ireg.getException());
+ assertNull(ireg.getImportedEndpoint());
+ assertNull(ireg.getImportedService());
}
@Test
@@ -51,10 +51,10 @@ public class ImportRegistrationImplTest {
c.replay();
- ImportRegistrationImpl i = new ImportRegistrationImpl(endpoint, closeHandler, null);
+ ImportRegistrationImpl ireg = new ImportRegistrationImpl(endpoint, closeHandler, null);
- assertNull(i.getException());
- assertEquals(endpoint, i.getImportedEndpoint());
+ assertNull(ireg.getException());
+ assertEquals(endpoint, ireg.getImportedEndpoint());
}
@SuppressWarnings("rawtypes")
@@ -70,51 +70,51 @@ public class ImportRegistrationImplTest {
c.replay();
- ImportRegistrationImpl i1 = new ImportRegistrationImpl(endpoint, closeHandler, null);
- i1.init(null, sr);
+ ImportRegistrationImpl ireg1 = new ImportRegistrationImpl(endpoint, closeHandler, null);
+ ireg1.init(null, sr);
- ImportRegistrationImpl i2 = new ImportRegistrationImpl(i1);
+ ImportRegistrationImpl ireg2 = new ImportRegistrationImpl(ireg1);
- ImportRegistrationImpl i3 = new ImportRegistrationImpl(i2);
+ ImportRegistrationImpl ireg3 = new ImportRegistrationImpl(ireg2);
try {
- i2.init(null, sr);
+ ireg2.init(null, sr);
fail("An exception should be thrown here !");
} catch (IllegalStateException e) {
// must be thrown here
}
- assertEquals(endpoint, i1.getImportedEndpoint());
- assertEquals(endpoint, i2.getImportedEndpoint());
- assertEquals(endpoint, i3.getImportedEndpoint());
+ assertEquals(endpoint, ireg1.getImportedEndpoint());
+ assertEquals(endpoint, ireg2.getImportedEndpoint());
+ assertEquals(endpoint, ireg3.getImportedEndpoint());
c.verify();
c.reset();
- closeHandler.onClose(EasyMock.eq(i3));
+ closeHandler.onClose(EasyMock.eq(ireg3));
EasyMock.expectLastCall().once();
c.replay();
- i3.close();
- i3.close(); // shouldn't change anything
+ ireg3.close();
+ ireg3.close(); // shouldn't change anything
- assertNull(i3.getImportedEndpoint());
+ assertNull(ireg3.getImportedEndpoint());
c.verify();
c.reset();
- closeHandler.onClose(EasyMock.eq(i1));
+ closeHandler.onClose(EasyMock.eq(ireg1));
EasyMock.expectLastCall().once();
c.replay();
- i1.close();
+ ireg1.close();
c.verify();
c.reset();
- closeHandler.onClose(EasyMock.eq(i2));
+ closeHandler.onClose(EasyMock.eq(ireg2));
EasyMock.expectLastCall().once();
sr.unregister();
@@ -122,7 +122,7 @@ public class ImportRegistrationImplTest {
c.replay();
- i2.close();
+ ireg2.close();
c.verify();
}
@@ -135,32 +135,32 @@ public class ImportRegistrationImplTest {
c.replay();
- ImportRegistrationImpl i1 = new ImportRegistrationImpl(endpoint, closeHandler, null);
+ ImportRegistrationImpl ireg1 = new ImportRegistrationImpl(endpoint, closeHandler, null);
- ImportRegistrationImpl i2 = new ImportRegistrationImpl(i1);
+ ImportRegistrationImpl ireg2 = new ImportRegistrationImpl(ireg1);
- ImportRegistrationImpl i3 = new ImportRegistrationImpl(i2);
+ ImportRegistrationImpl ireg3 = new ImportRegistrationImpl(ireg2);
c.verify();
c.reset();
- closeHandler.onClose(EasyMock.eq(i2));
+ closeHandler.onClose(EasyMock.eq(ireg2));
EasyMock.expectLastCall().once();
c.replay();
- i2.close();
+ ireg2.close();
c.verify();
c.reset();
- closeHandler.onClose(EasyMock.eq(i1));
+ closeHandler.onClose(EasyMock.eq(ireg1));
EasyMock.expectLastCall().once();
- closeHandler.onClose(EasyMock.eq(i3));
+ closeHandler.onClose(EasyMock.eq(ireg3));
EasyMock.expectLastCall().once();
c.replay();
- i3.closeAll();
+ ireg3.closeAll();
c.verify();
}
}
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
index 3e89de51..779d422c 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
@@ -126,10 +126,10 @@ public class RemoteServiceAdminCoreTest {
c.replay();
- List<ExportRegistration> exRefs = rsaCore.exportService(sref, null);
+ List<ExportRegistration> eregs = rsaCore.exportService(sref, null);
- assertNotNull(exRefs);
- assertEquals(0, exRefs.size());
+ assertNotNull(eregs);
+ assertEquals(0, eregs.size());
assertEquals(rsaCore.getExportedServices().size(), 0);
c.verify();
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/event/EventAdminSenderTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/event/EventAdminSenderTest.java
index 554fb24d..d79117f6 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/event/EventAdminSenderTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/event/EventAdminSenderTest.java
@@ -50,10 +50,10 @@ public class EventAdminSenderTest {
EasyMock.replay(epd);
final ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
EasyMock.replay(sref);
- final ExportReference er = EasyMock.createNiceMock(ExportReference.class);
- EasyMock.expect(er.getExportedEndpoint()).andReturn(epd).anyTimes();
- EasyMock.expect(er.getExportedService()).andReturn(sref).anyTimes();
- EasyMock.replay(er);
+ final ExportReference eref = EasyMock.createNiceMock(ExportReference.class);
+ EasyMock.expect(eref.getExportedEndpoint()).andReturn(epd).anyTimes();
+ EasyMock.expect(eref.getExportedService()).andReturn(sref).anyTimes();
+ EasyMock.replay(eref);
final Bundle bundle = EasyMock.createNiceMock(Bundle.class);
EasyMock.expect(bundle.getBundleId()).andReturn(42L).anyTimes();
@@ -93,9 +93,9 @@ public class EventAdminSenderTest {
Assert.assertNull(rsae.getException());
Assert.assertEquals(RemoteServiceAdminEvent.EXPORT_REGISTRATION, rsae.getType());
Assert.assertSame(bundle, rsae.getSource());
- ExportReference er = rsae.getExportReference();
- Assert.assertSame(epd, er.getExportedEndpoint());
- Assert.assertSame(sref, er.getExportedService());
+ ExportReference eref = rsae.getExportReference();
+ Assert.assertSame(epd, eref.getExportedEndpoint());
+ Assert.assertSame(sref, eref.getExportedService());
return null;
}
@@ -114,11 +114,11 @@ public class EventAdminSenderTest {
RemoteServiceAdminEvent event = new RemoteServiceAdminEvent(
RemoteServiceAdminEvent.EXPORT_REGISTRATION,
bundle,
- er,
+ eref,
null
);
new EventAdminSender(bc).send(event);
- EasyMock.verify(epd, sref, er, ea, eaSref, bc);
+ EasyMock.verify(epd, sref, eref, ea, eaSref, bc);
}
@Test
@@ -128,10 +128,10 @@ public class EventAdminSenderTest {
EasyMock.replay(epd);
final ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
EasyMock.replay(sref);
- final ExportReference er = EasyMock.createNiceMock(ExportReference.class);
- EasyMock.expect(er.getExportedEndpoint()).andReturn(epd).anyTimes();
- EasyMock.expect(er.getExportedService()).andReturn(sref).anyTimes();
- EasyMock.replay(er);
+ final ExportReference eref = EasyMock.createNiceMock(ExportReference.class);
+ EasyMock.expect(eref.getExportedEndpoint()).andReturn(epd).anyTimes();
+ EasyMock.expect(eref.getExportedService()).andReturn(sref).anyTimes();
+ EasyMock.replay(eref);
final Bundle bundle = EasyMock.createNiceMock(Bundle.class);
EasyMock.expect(bundle.getBundleId()).andReturn(42L).anyTimes();
@@ -163,9 +163,9 @@ public class EventAdminSenderTest {
Assert.assertSame(exportException, rsae.getException());
Assert.assertEquals(RemoteServiceAdminEvent.EXPORT_ERROR, rsae.getType());
Assert.assertSame(bundle, rsae.getSource());
- ExportReference er = rsae.getExportReference();
- Assert.assertSame(epd, er.getExportedEndpoint());
- Assert.assertSame(sref, er.getExportedService());
+ ExportReference eref = rsae.getExportReference();
+ Assert.assertSame(epd, eref.getExportedEndpoint());
+ Assert.assertSame(sref, eref.getExportedService());
return null;
}
@@ -185,10 +185,10 @@ public class EventAdminSenderTest {
RemoteServiceAdminEvent event = new RemoteServiceAdminEvent(
RemoteServiceAdminEvent.EXPORT_ERROR,
bundle,
- er,
+ eref,
exportException
);
new EventAdminSender(bc).send(event);
- EasyMock.verify(epd, sref, er, ea, eaSref, bc);
+ EasyMock.verify(epd, sref, eref, ea, eaSref, bc);
}
}
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/event/EventProducerTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/event/EventProducerTest.java
index f123598b..c3ed43bf 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/event/EventProducerTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/event/EventProducerTest.java
@@ -84,9 +84,9 @@ public class EventProducerTest {
Assert.assertNull(rsae.getException());
Assert.assertEquals(RemoteServiceAdminEvent.EXPORT_REGISTRATION, rsae.getType());
Assert.assertSame(bundle, rsae.getSource());
- ExportReference er = rsae.getExportReference();
- Assert.assertSame(epd, er.getExportedEndpoint());
- Assert.assertSame(sref, er.getExportedService());
+ ExportReference eref = rsae.getExportReference();
+ Assert.assertSame(epd, eref.getExportedEndpoint());
+ Assert.assertSame(sref, eref.getExportedService());
c.verify();
}
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/ServiceExportsRepository.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/ServiceExportsRepository.java
index 61e25f7c..040d160c 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/ServiceExportsRepository.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/ServiceExportsRepository.java
@@ -63,13 +63,13 @@ public class ServiceExportsRepository implements Closeable {
new ArrayList<>(exports.keySet()).forEach(this::removeService); // iterate over copy to avoid CME
}
- public synchronized void addService(ServiceReference<?> sref, Collection<ExportRegistration> registrations) {
+ public synchronized void addService(ServiceReference<?> sref, Collection<ExportRegistration> eregs) {
Map<ExportRegistration, EndpointDescription> regs = new LinkedHashMap<>();
- for (ExportRegistration reg : registrations) {
- ExportReference ref = reg.getException() != null ? null : reg.getExportReference();
- EndpointDescription endpoint = ref == null ? null : ref.getExportedEndpoint();
+ for (ExportRegistration ereg : eregs) {
+ ExportReference eref = ereg.getException() != null ? null : ereg.getExportReference();
+ EndpointDescription endpoint = eref == null ? null : eref.getExportedEndpoint();
if (endpoint != null) {
- regs.put(reg, endpoint);
+ regs.put(ereg, endpoint);
notifier.sendEvent(new EndpointEvent(EndpointEvent.ADDED, endpoint));
}
}
@@ -79,10 +79,10 @@ public class ServiceExportsRepository implements Closeable {
}
public synchronized void modifyService(ServiceReference<?> sref) {
- Map<ExportRegistration, EndpointDescription> regs = exports.get(sref);
- if (regs != null) {
+ Map<ExportRegistration, EndpointDescription> eregs = exports.get(sref);
+ if (eregs != null) {
Map<String, ?> props = getServiceProps(sref);
- for (Map.Entry<ExportRegistration, EndpointDescription> entry: regs.entrySet()) {
+ for (Map.Entry<ExportRegistration, EndpointDescription> entry: eregs.entrySet()) {
try {
EndpointDescription updated = entry.getKey().update(props);
if (updated != null) {
@@ -97,11 +97,11 @@ public class ServiceExportsRepository implements Closeable {
}
public synchronized void removeService(ServiceReference<?> sref) {
- Map<ExportRegistration, EndpointDescription> regs = exports.remove(sref);
- if (regs != null) {
- regs.forEach((reg, endpoint) -> {
+ Map<ExportRegistration, EndpointDescription> eregs = exports.remove(sref);
+ if (eregs != null) {
+ eregs.forEach((ereg, endpoint) -> {
notifier.sendEvent(new EndpointEvent(EndpointEvent.REMOVED, endpoint));
- reg.close();
+ ereg.close();
});
}
}
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExport.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExport.java
index 751de5f7..07b9e251 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExport.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExport.java
@@ -143,13 +143,13 @@ public class TopologyManagerExport implements ServiceListener {
LOG.debug("exporting Service {} using RemoteServiceAdmin {}", sref, rsa.getClass().getName());
Map<String, ?> addProps = policy.additionalParameters(sref);
- Collection<ExportRegistration> regs = rsa.exportService(sref, addProps);
- if (regs.isEmpty()) {
+ Collection<ExportRegistration> eregs = rsa.exportService(sref, addProps);
+ if (eregs.isEmpty()) {
LOG.warn("no supported configs found for exporting service {}", sref);
}
// process successful/failed registrations
- for (ExportRegistration reg : regs) {
+ for (ExportRegistration reg : eregs) {
if (reg.getException() == null) {
EndpointDescription endpoint = reg.getExportReference().getExportedEndpoint();
LOG.info("TopologyManager: export succeeded for {}, endpoint {}, rsa {}", sref, endpoint, rsa.getClass().getName());
@@ -163,12 +163,12 @@ public class TopologyManagerExport implements ServiceListener {
// with the unregister event which may have already been handled, so we'll miss it)
if (sref.getBundle() == null) {
LOG.info("TopologyManager: export reverted for {} since service was unregistered", sref);
- for (ExportRegistration reg : regs) {
+ for (ExportRegistration reg : eregs) {
reg.close();
}
}
- return regs;
+ return eregs;
}
private boolean shouldExport(ServiceReference<?> sref) {
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImport.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImport.java
index 678241dc..be32e3d3 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImport.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImport.java
@@ -110,11 +110,11 @@ public class TopologyManagerImport implements EndpointEventListener, RemoteServi
@Override
public void remoteAdminEvent(RemoteServiceAdminEvent event) {
- ImportReference ref = event.getImportReference();
- if (event.getType() == RemoteServiceAdminEvent.IMPORT_UNREGISTRATION && ref != null) {
+ ImportReference iref = event.getImportReference();
+ if (event.getType() == RemoteServiceAdminEvent.IMPORT_UNREGISTRATION && iref != null) {
synchronized (this) {
List<ImportRegistration> closing = importedServices.allValues().stream()
- .filter(reg -> ref.equals(reg.getImportReference()))
+ .filter(reg -> iref.equals(reg.getImportReference()))
.collect(Collectors.toList()); // make a copy to prevent CME
closing.forEach(this::unimportRegistration);
}
@@ -153,18 +153,18 @@ public class TopologyManagerImport implements EndpointEventListener, RemoteServi
Set<EndpointDescription> valid = new HashSet<>(); // imports that are still valid and possible
Set<ImportRegistration> invalid = new LinkedHashSet<>(); // imports that are no longer valid/possible
Map<ImportRegistration, EndpointDescription> updated = new LinkedHashMap<>(); // valid with changed props
- for (ImportRegistration reg : imported) {
- ImportReference ref = reg.getImportReference();
- EndpointDescription endpoint = ref == null ? null : ref.getImportedEndpoint();
+ for (ImportRegistration ireg : imported) {
+ ImportReference iref = ireg.getImportReference();
+ EndpointDescription endpoint = iref == null ? null : iref.getImportedEndpoint();
// check if the currently imported endpoint is still valid and possible
EndpointDescription pe = possible.get(endpoint); // get the new (maybe modified) possible endpoint
if (pe != null) {
if (getChangedKeys(endpoint.getProperties(), pe.getProperties()).isEmpty())
valid.add(endpoint); // valid and possible
else
- updated.put(reg, pe); // valid and possible and changed properties
+ updated.put(ireg, pe); // valid and possible and changed properties
} else {
- invalid.add(reg); // invalid (reg or ref or endpoint is null) or no longer possible
+ invalid.add(ireg); // invalid (reg or ref or endpoint is null) or no longer possible
}
}
// now that we figured out what needs to be done, apply the changes to each group
@@ -195,23 +195,23 @@ public class TopologyManagerImport implements EndpointEventListener, RemoteServi
*/
private void importService(String filter, EndpointDescription endpoint) {
for (RemoteServiceAdmin rsa : rsaSet) {
- ImportRegistration reg = rsa.importService(endpoint);
- if (reg != null) {
- if (reg.getException() == null) {
- LOG.debug("Service import was successful {}", reg);
- importedServices.put(filter, reg);
+ ImportRegistration ireg = rsa.importService(endpoint);
+ if (ireg != null) {
+ if (ireg.getException() == null) {
+ LOG.debug("Service import was successful {}", ireg);
+ importedServices.put(filter, ireg);
return;
} else {
- LOG.warn("Error importing service {}", endpoint, reg.getException());
- reg.close();
+ LOG.warn("Error importing service {}", endpoint, ireg.getException());
+ ireg.close();
}
}
}
}
- private void unimportRegistration(ImportRegistration reg) {
- importedServices.remove(reg);
- reg.close();
+ private void unimportRegistration(ImportRegistration ireg) {
+ importedServices.remove(ireg);
+ ireg.close();
}
@Override
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExportTest.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExportTest.java
index f34300b7..77af1070 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExportTest.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExportTest.java
@@ -160,9 +160,9 @@ public class TopologyManagerExportTest {
private void expectServiceExported(
final ServiceReference sref,
EndpointDescription epd) {
- ExportRegistration exportRegistration = createExportRegistration(c, epd);
+ ExportRegistration ereg = createExportRegistration(c, epd);
expect(rsa.exportService(EasyMock.same(sref), EasyMock.anyObject()))
- .andReturn(Collections.singletonList(exportRegistration)).once();
+ .andReturn(Collections.singletonList(ereg)).once();
}
private Executor syncExecutor() {
@@ -175,15 +175,15 @@ public class TopologyManagerExportTest {
}
private ExportRegistration createExportRegistration(IMocksControl c, EndpointDescription endpoint) {
- ExportRegistration exportRegistration = c.createMock(ExportRegistration.class);
- ExportReference exportReference = c.createMock(ExportReference.class);
- expect(exportRegistration.getExportReference()).andReturn(exportReference).anyTimes();
- expect(exportRegistration.getException()).andReturn(null).anyTimes();
- expect(exportReference.getExportedEndpoint()).andReturn(endpoint).anyTimes();
- exportRegistration.close();
+ ExportRegistration ereg = c.createMock(ExportRegistration.class);
+ ExportReference eref = c.createMock(ExportReference.class);
+ expect(ereg.getExportReference()).andReturn(eref).anyTimes();
+ expect(ereg.getException()).andReturn(null).anyTimes();
+ expect(eref.getExportedEndpoint()).andReturn(endpoint).anyTimes();
+ ereg.close();
expectLastCall().anyTimes();
- expect(exportRegistration.update(EasyMock.anyObject(Map.class))).andReturn(endpoint).anyTimes();
- return exportRegistration;
+ expect(ereg.update(EasyMock.anyObject(Map.class))).andReturn(endpoint).anyTimes();
+ return ereg;
}
private EndpointDescription createEndpoint() {
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImportTest.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImportTest.java
index af29da5c..972a35f6 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImportTest.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImportTest.java
@@ -74,15 +74,15 @@ public class TopologyManagerImportTest {
props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "config1");
EndpointDescription endpoint = new EndpointDescription(props);
- final ImportRegistration ir = mockImportRegistration(c, endpoint, expectUpdate);
- ir.close(); // must be closed
+ final ImportRegistration ireg = mockImportRegistration(c, endpoint, expectUpdate);
+ ireg.close(); // must be closed
expectLastCall().andAnswer(() -> {
endpoints.get(endpoint).decrementAndGet();
return null;
});
expect(rsa.importService(eq(endpoint))).andAnswer(() -> {
endpoints.get(endpoint).incrementAndGet();
- return ir;
+ return ireg;
});
endpoints.put(endpoint, new AtomicInteger());
return endpoint;