[FELIX-4989] CopyOnWriteList.removeAll(Collection<?>) is incorrect causing failures for multiple cardinality resolution

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1696529 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteList.java b/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteList.java
index b11e15b..b604434 100644
--- a/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteList.java
+++ b/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteList.java
@@ -183,11 +183,12 @@
         int idx = 0;
         for (int i = 0, l = o.length; i < l; i++) {
             if (c.contains(o[i])) {
-                modified = true;
-            } else if (modified) {
-                if (idx == 0) {
+                if (!modified) {
                     d = o.clone();
+                    idx = i;
+                    modified = true;
                 }
+            } else if (modified) {
                 d[idx++] = o[i];
             }
         }