[maven-release-plugin]  copy for tag cxf-dosgi-ri-1.5.0

git-svn-id: https://svn.apache.org/repos/asf/cxf/dosgi/tags/cxf-dosgi-ri-1.5.0@1497664 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/distribution/sources/src/main/release/release_notes.txt b/distribution/sources/src/main/release/release_notes.txt
index 0b29007..ca7e9d6 100644
--- a/distribution/sources/src/main/release/release_notes.txt
+++ b/distribution/sources/src/main/release/release_notes.txt
@@ -1,5 +1,49 @@
 See: http://cxf.apache.org/dosgi-releases.html
 
+Release Notes - CXF Distributed OSGi - Version 1.5.0
+====================================================
+
+** Bug
+    * [DOSGI-158] - NPE on shutdown of DOSGi service
+    * [DOSGI-160] - RemoteServiceAdmin shuts itself down during startup
+    * [DOSGI-161] - services sometimes don't get exported
+    * [DOSGI-162] - Compilation errors when using OSGi core
+    * 4.3.0/4.3.1/5.0.0
+    * [DOSGI-164] - NullPointerException on export
+    * [DOSGI-165] - exported service is not properly closed and cannot be
+    * restarted
+    * [DOSGI-166] - List can not be used to register CXF providers with DSW
+    * [DOSGI-168] - RemoteServiceAdminCore service parameters handling bugs
+    * [DOSGI-172] - o.a.c.d.discovery.zookeeper package classes are not
+    * properly synchronized
+    * [DOSGI-173] - unregistering an exported service does not remove it
+    * from zookeeper (and remote clients)
+    * [DOSGI-174] - synchronization issues and resource leaks in
+    * TopologyManagerImport and related classes
+    * [DOSGI-175] - TopologyManagerImport's reference counter doesn't count
+    * [DOSGI-176] - zookeeper discovery sending multiple duplicate endpoint
+    * notifications
+    * [DOSGI-177] - stopped services still appear as available to clients
+    * [DOSGI-180] - CXF service does not disappear if exporting bundle is
+    * stopped
+    * [DOSGI-188] - services aren't re-imported after RemoteServiceAdmin
+    * restart
+    * [DOSGI-190] - NodeExistsException and missing endpoint after ZooKeeper
+    * is restarted
+    * [DOSGI-191] - ZooKeeperDiscovery instance reconnects to ZooKeeper
+    * after bundle is stopped
+    * [DOSGI-192] - Upgrade to zookeeper 3.3.2 to fix bug with zk event
+    * thread shutdown
+    * [DOSGI-195] - Exceptions in tests: ClassCastException on
+    * SpringBusFactory
+
+** Improvement
+    * [DOSGI-167] - Upgrade Aries to the 1.x version for distro
+    * [DOSGI-170] - Remove single bundle distro
+    * [DOSGI-181] - Reactivate or delete old systests
+    * [DOSGI-184] - Split Endpoint repository from TopologyManagerExport
+    * [DOSGI-193] - Split discovery.zookeeper package into subpackages
+
 Apache CXF Distributed OSGi 1.4.0 Release Notes
 ===============================================
 
diff --git a/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/importer/TopologyManagerImport.java b/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/importer/TopologyManagerImport.java
index 40505ff..f3ee754 100644
--- a/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/importer/TopologyManagerImport.java
+++ b/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/importer/TopologyManagerImport.java
@@ -217,24 +217,15 @@
     private void unexportNotAvailableServices(String filter) {
         synchronized (importedServices) {
             List<ImportRegistration> importRegistrations = importedServices.get(filter);
-            if (importRegistrations == null) {
-                return;
-            }
-
-            Iterator<ImportRegistration> it = importRegistrations.iterator();
-            while (it.hasNext()) {
-                ImportRegistration ir = it.next();
-                EndpointDescription ep = ir.getImportReference().getImportedEndpoint();
-                if (!isImportPossibilityAvailable(ep, filter)) {
-                    // unexport service
-                    ir.close();
-                    it.remove();
+            if (importRegistrations != null) {
+                // iterate over a copy
+                for (ImportRegistration ir : new ArrayList<ImportRegistration>(importRegistrations)) {
+                    EndpointDescription ep = ir.getImportReference().getImportedEndpoint();
+                    if (!isImportPossibilityAvailable(ep, filter)) {
+                        removeImport(ir, null); // also unexports the service
+                    }
                 }
             }
-
-            if (importRegistrations.isEmpty()) {
-                importedServices.remove(filter);
-            }
         }
     }
 
@@ -308,13 +299,25 @@
         return null;
     }
 
-    public void removeImportReference(ImportReference importReference) {
+    /**
+     * Remove and close (unexport) the given import. The import is specified either
+     * by its ImportRegistration or by its ImportReference (only one of them must
+     * be specified).
+     * <p>
+     * If this method is called from within iterations on the underlying data structure,
+     * the iterations must be made on copies of the structures rather than the original
+     * references in order to prevent ConcurrentModificationExceptions.
+     *
+     * @param reg the import registration to remove
+     * @param ref the import reference to remove
+     */
+    private void removeImport(ImportRegistration reg, ImportReference ref) {
         synchronized (importedServices) {
             for (Iterator<List<ImportRegistration>> it1 = importedServices.values().iterator(); it1.hasNext();) {
                 Collection<ImportRegistration> irs = it1.next();
                 for (Iterator<ImportRegistration> it2 = irs.iterator(); it2.hasNext();) {
                     ImportRegistration ir = it2.next();
-                    if (ir.getImportReference().equals(importReference)) {
+                    if (ir.equals(reg) || ir.getImportReference().equals(ref)) {
                         ir.close();
                         it2.remove();
                     }
@@ -328,7 +331,7 @@
 
     public void remoteAdminEvent(RemoteServiceAdminEvent event) {
         if (event.getType() == RemoteServiceAdminEvent.IMPORT_UNREGISTRATION) {
-            removeImportReference(event.getImportReference());
+            removeImport(null, event.getImportReference());
         }
     }
 }
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
index 1252d3f..8d99885 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
@@ -19,6 +19,7 @@
 package org.apache.cxf.dosgi.systests2.multi;
 
 import java.io.IOException;
+import java.net.ConnectException;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.ServerSocket;
@@ -110,11 +111,14 @@
     protected void waitWebPage(String urlSt) throws InterruptedException {
         int status = 0;
         int seconds = 0;
+        System.out.println("Waiting for url " + urlSt);
         while (status != 200) {
             try {
                 URL url = new URL(urlSt);
                 HttpURLConnection con = (HttpURLConnection)url.openConnection();
                 status = con.getResponseCode();
+            } catch (ConnectException e) {
+                // Ignore connection refused
             } catch (MalformedURLException e) {
                 throw new RuntimeException(e.getMessage(), e);
             } catch (IOException e) {
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
index 8e6be6b..35a2efb 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
@@ -41,12 +41,14 @@
 
     @Inject
     BundleContext bundleContext;
+    
+    String webPort = "9091";
 
     @Configuration
-    public static Option[] configure() throws Exception {
+    public Option[] configure() throws Exception {
         return new Option[] {
                 MultiBundleTools.getDistroWithDiscovery(),
-                systemProperty("org.osgi.service.http.port").value("9090"),
+                systemProperty("org.osgi.service.http.port").value(webPort),
                 systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
                 mavenBundle().groupId("org.apache.servicemix.bundles")
                     .artifactId("org.apache.servicemix.bundles.junit").version("4.9_2"),
@@ -60,11 +62,10 @@
 
     @Test
     public void testEndpointAvailable() throws Exception {
-        waitWebPage("http://localhost:9090/greeter/greeter/greeting/Chris");
+        waitWebPage("http://localhost:" + webPort + "/greeter/greeter/greeting/Chris");
         try {
-            
             Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
-            GreeterService greeterService = JAXRSClientFactory.create("http://localhost:9090/greeter",
+            GreeterService greeterService = JAXRSClientFactory.create("http://localhost:" + webPort + "/greeter",
                                                                       GreeterService.class);
             GreeterInfo result = greeterService.greetMe("Chris");
             GreetingPhrase greeting = result.getGreetings().get(0);