This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
The following commit(s) were added to refs/heads/master by this push: new f40a512 ARIES-1940 Handle failure that can happen during service export (#30) f40a512 is described below commit f40a512a43d2ebf5a7896dbe4559b3ac03c0394f Author: Arnoud Glimmerveen <arn...@glimmerveen.org> AuthorDate: Fri Nov 8 17:00:06 2019 +0100 ARIES-1940 Handle failure that can happen during service export (#30) Changed implementation and use of ExportRegistration to align with specification Changed use of ExportRegistration to deal with cases the ExportRegistration relates to a failed exported services --- .../org/apache/aries/rsa/core/ExportRegistrationImpl.java | 13 ++++++++----- .../org/apache/aries/rsa/core/RemoteServiceAdminCore.java | 12 ++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/ExportRegistrationImpl.java b/rsa/src/main/java/org/apache/aries/rsa/core/ExportRegistrationImpl.java index a02ff3a..715efd2 100644 --- a/rsa/src/main/java/org/apache/aries/rsa/core/ExportRegistrationImpl.java +++ b/rsa/src/main/java/org/apache/aries/rsa/core/ExportRegistrationImpl.java @@ -99,12 +99,15 @@ public class ExportRegistrationImpl implements ExportRegistration { } public ExportReference getExportReference() { - /* TODO check if we need to throw exception here - if (exportReference == null) { - throw new IllegalStateException(getException()); + if (closed) { + return null; + } else { + if (exportReference == null) { + throw new IllegalStateException(getException()); + } else { + return exportReference; + } } - */ - return closed ? null : exportReference; } public Throwable getException() { 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 d48283c..207c98a 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 @@ -379,7 +379,7 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin { List<ExportReference> ers = new ArrayList<>(); for (Collection<ExportRegistration> exportRegistrations : exportedServices.values()) { for (ExportRegistration er : exportRegistrations) { - if (er.getExportReference() != null) { + if (er.getException() == null && er.getExportReference() != null) { ers.add(new ExportReferenceImpl(er.getExportReference())); } } @@ -502,7 +502,9 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin { synchronized (exportedServices) { for (Collection<ExportRegistration> value : exportedServices.values()) { for (ExportRegistration er : value) { - if (er.getExportReference().getExportedService().equals(sref)) { + if (er.getException() != null && + er.getExportReference() != null && + er.getExportReference().getExportedService().equals(sref)) { regs.add(er); } } @@ -530,7 +532,9 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin { for (Iterator<ExportRegistration> it2 = value.iterator(); it2.hasNext();) { ExportRegistration er = it2.next(); if (er.equals(eri)) { - eventProducer.notifyRemoval(eri.getExportReference()); + if (eri.getException() == null && eri.getExportReference() != null) { + eventProducer.notifyRemoval(eri.getExportReference()); + } it2.remove(); if (value.isEmpty()) { it.remove(); @@ -569,7 +573,7 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin { for (Collection<ExportRegistration> regs : exportedServices.values()) { if (!regs.isEmpty()) { ExportRegistration exportRegistration = regs.iterator().next(); - if (exportRegistration.getException() == null) { + if (exportRegistration.getException() == null && exportRegistration.getExportReference() != null) { Bundle regBundle = exportRegistration.getExportReference().getExportedService().getBundle(); if (exportingBundle.equals(regBundle)) { bundleRegs.addAll(regs);