You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by da...@apache.org on 2018/11/07 10:15:16 UTC

[sling-whiteboard] branch master updated: Improve diagnostics on the candidate removal log message

This is an automated email from the ASF dual-hosted git repository.

davidb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 89365d8  Improve diagnostics on the candidate removal log message
89365d8 is described below

commit 89365d89c8d012a4351d179e180a955c4c236a6a
Author: David Bosschaert <bo...@adobe.com>
AuthorDate: Wed Nov 7 10:14:30 2018 +0000

    Improve diagnostics on the candidate removal log message
---
 .../feature/apiregions/impl/ResolverHookImpl.java  | 23 +++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/featuremodel/feature-apiregions/src/main/java/org/apache/sling/feature/apiregions/impl/ResolverHookImpl.java b/featuremodel/feature-apiregions/src/main/java/org/apache/sling/feature/apiregions/impl/ResolverHookImpl.java
index e754c31..34f4409 100644
--- a/featuremodel/feature-apiregions/src/main/java/org/apache/sling/feature/apiregions/impl/ResolverHookImpl.java
+++ b/featuremodel/feature-apiregions/src/main/java/org/apache/sling/feature/apiregions/impl/ResolverHookImpl.java
@@ -30,6 +30,7 @@ import java.util.AbstractMap;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -97,6 +98,7 @@ class ResolverHookImpl implements ResolverHook {
 
         Set<BundleCapability> coveredCaps = new HashSet<>();
 
+        Map<BundleCapability, Set<String>> bcRegionMap = new HashMap<>();
         nextCapability:
         for (BundleCapability bc : candidates) {
             BundleRevision rev = bc.getRevision();
@@ -154,6 +156,7 @@ class ResolverHookImpl implements ResolverHook {
                     coveredCaps.add(bc);
                     continue nextCapability;
                 }
+                bcRegionMap.put(bc, capRegions);
 
                 HashSet<String> sharedRegions = new HashSet<String>(reqRegions);
                 sharedRegions.retainAll(capRegions);
@@ -181,10 +184,28 @@ class ResolverHookImpl implements ResolverHook {
             }
         }
 
+        List<BundleCapability> removedCandidates = new ArrayList<>(candidates);
         // Remove any capabilities that are not covered
         if (candidates.retainAll(coveredCaps)) {
+            removedCandidates.removeAll(candidates);
+
+            StringBuilder sb = new StringBuilder();
+            boolean first = true;
+            for (BundleCapability bc : removedCandidates) {
+                if (first)
+                    first = false;
+                else
+                    sb.append(", ");
+
+                sb.append(bc.toString());
+                sb.append("[Regions: ");
+                sb.append(bcRegionMap.get(bc));
+                sb.append("]");
+            }
+
             LOG.log(Level.INFO,
-                    "Removed one ore more candidates for requirement {0} as they are not in the correct region", requirement);
+                    "API-Regions removed candidates {0} for requirement {1} as the requirement is in the following regions: {2}",
+                    new Object[] {sb, requirement, reqRegions});
         }
     }