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-org-apache-sling-feature-apiregions.git
The following commit(s) were added to refs/heads/master by this push:
new 04fb58b SLING-9494 Always log which candidates where removed by the
API Regions
new 67f065b Merge pull request #9 from bosschaert/SLING-9494
04fb58b is described below
commit 04fb58bc44eae2a1dabb9a0dc8379dae90cafd67
Author: David Bosschaert <[email protected]>
AuthorDate: Tue Jun 2 17:05:41 2020 +0100
SLING-9494 Always log which candidates where removed by the API Regions
---
.../feature/apiregions/impl/ResolverHookImpl.java | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git
a/src/main/java/org/apache/sling/feature/apiregions/impl/ResolverHookImpl.java
b/src/main/java/org/apache/sling/feature/apiregions/impl/ResolverHookImpl.java
index 9dbeccf..1476fc4 100644
---
a/src/main/java/org/apache/sling/feature/apiregions/impl/ResolverHookImpl.java
+++
b/src/main/java/org/apache/sling/feature/apiregions/impl/ResolverHookImpl.java
@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
+import java.util.stream.Collectors;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;
@@ -160,9 +161,15 @@ class ResolverHookImpl implements ResolverHook {
// Remove any capabilities that are not covered
candidates.retainAll(coveredCaps.keySet());
+ Level logLevel;
if (candidates.isEmpty()) {
- removedCandidates.removeAll(candidates);
+ logLevel = Level.WARNING;
+ } else {
+ logLevel = Level.INFO;
+ }
+ removedCandidates.removeAll(candidates);
+ if (!removedCandidates.isEmpty()) {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (BundleCapability bc : removedCandidates) {
@@ -180,7 +187,7 @@ class ResolverHookImpl implements ResolverHook {
sb.append("]");
}
- Activator.LOG.log(Level.WARNING,
+ Activator.LOG.log(logLevel,
"API-Regions removed candidates {0} for requirement {1} as
the requirement is in the following regions: {2} and in feature: {3}",
new Object[] {sb, requirement, reqRegions, reqFeatures});
}
@@ -235,8 +242,14 @@ class ResolverHookImpl implements ResolverHook {
// There are specific capabilities, therefore we should remove the
Global region is any from the capabilities
// We have collected the capabilities we want to keep in specificCaps
for (Iterator<BundleCapability> it = capMap.keySet().iterator();
it.hasNext(); ) {
- if (!specificCaps.contains(it.next())) {
+ BundleCapability cap = it.next();
+ if (!specificCaps.contains(cap)) {
it.remove();
+ Activator.LOG.log(Level.INFO, "Removing candidate {0} which is
in region {1} as more specific candidates are available in regions {2}",
+ new Object[] {
+ cap, capMap.get(cap),
+ specificCaps.stream().map(c -> "" + c + "
region " + capMap.get(c)).collect(Collectors.joining("/"))
+ });
}
}
}