karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [karaf] 03/05: When removing a features repository, handle the fact that another repo can provide the required feature
Date Sat, 11 Nov 2017 19:25:22 GMT
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git

commit 634ba15a955f7d17ee60f0ae1547b8ecea9957ca
Author: Guillaume Nodet <gnodet@gmail.com>
AuthorDate: Tue Nov 7 11:19:05 2017 +0100

    When removing a features repository, handle the fact that another repo can provide the
required feature
---
 .../internal/service/FeaturesServiceImpl.java      | 35 +++++++++++++++-------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
index 4301448..1478385 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
@@ -392,24 +392,39 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
             return;
         }
 
-        Set<Repository> repos;
+        Map<String, Set<String>> reqsToRemove;
         Set<String> features;
         synchronized (lock) {
-            repos = repositories.getRepositoryClosure(repo);
-            List<Repository> required = new ArrayList<>(Arrays.asList(repositories.listMatchingRepositories(state.repositories)));
-            required.remove(repo);
-            for (Repository rep : required) {
-                repos.removeAll(repositories.getRepositoryClosure(rep));
-            }
+            getFeatureCache();
             features = new HashSet<>();
-            for (Repository tranRepo : repos) {
-                features.addAll(getRequiredFeatureIds(tranRepo));
+            for (Set<String> reqs : state.requirements.values()) {
+                features.addAll(reqs);
+            }
+            Set<Repository> repos = new HashSet<>();
+            for (String r : state.repositories) {
+                if (!uri.toString().equals(r)) {
+                    Repository rep = repositories.getRepository(r);
+                    repos.addAll(repositories.getRepositoryClosure(rep));
+                }
+            }
+            for (Repository rep : repos) {
+                for (Feature f : rep.getFeatures()) {
+                    features.remove(new FeatureReq(f).toRequirement());
+                }
+            }
+            reqsToRemove = new HashMap<>();
+            for (Map.Entry<String, Set<String>> entry : state.requirements.entrySet())
{
+                Set<String> reqs = new HashSet<>(entry.getValue());
+                reqs.retainAll(features);
+                if (!reqs.isEmpty()) {
+                    reqsToRemove.put(entry.getKey(), reqs);
+                }
             }
         }
 
         if (!features.isEmpty()) {
             if (uninstall) {
-                uninstallFeatures(features, EnumSet.noneOf(Option.class));
+                removeRequirements(reqsToRemove, EnumSet.noneOf(Option.class));
             } else {
                 throw new IllegalStateException("The following features are required from
the repository: " + String.join(", ", features));
             }

-- 
To stop receiving notification emails like this one, please contact
"commits@karaf.apache.org" <commits@karaf.apache.org>.

Mime
View raw message