This is an automated email from the ASF dual-hosted git repository.
pauls pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-resolver.git
The following commit(s) were added to refs/heads/master by this push:
new eb9743b SLING-11093: only register the absolute resource type if the
relative resource type is the same (#26)
eb9743b is described below
commit eb9743bd2086a9998105437e40b5f473990a7f07
Author: Karl Pauls <[email protected]>
AuthorDate: Wed Jan 26 17:42:33 2022 +0100
SLING-11093: only register the absolute resource type if the relative
resource type is the same (#26)
---
.../resolver/internal/bundle/BundledScriptTracker.java | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git
a/src/main/java/org/apache/sling/servlets/resolver/internal/bundle/BundledScriptTracker.java
b/src/main/java/org/apache/sling/servlets/resolver/internal/bundle/BundledScriptTracker.java
index 6454e63..62f8726 100644
---
a/src/main/java/org/apache/sling/servlets/resolver/internal/bundle/BundledScriptTracker.java
+++
b/src/main/java/org/apache/sling/servlets/resolver/internal/bundle/BundledScriptTracker.java
@@ -54,6 +54,7 @@ import org.apache.sling.api.SlingConstants;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.request.RequestDispatcherOptions;
+import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.resource.type.ResourceType;
import org.apache.sling.api.servlets.ServletResolverConstants;
@@ -110,6 +111,9 @@ public class BundledScriptTracker implements
BundleTrackerCustomizer<List<Servic
@Reference
private ServletMounter mounter;
+ @Reference
+ private ResourceResolverFactory resourceResolverFactory;
+
private AtomicReference<BundleContext> bundleContext = new
AtomicReference<>();
private AtomicReference<BundleTracker<List<ServiceRegistration<Servlet>>>>
tracker = new AtomicReference<>();
private AtomicReference<Map<Set<String>, ServiceRegistration<Servlet>>>
dispatchers = new AtomicReference<>();
@@ -163,11 +167,21 @@ public class BundledScriptTracker implements
BundleTrackerCustomizer<List<Servic
LinkedHashSet<TypeProvider> inheritanceChain = new
LinkedHashSet<>();
inheritanceChain.add(baseTypeProvider);
if
(!bundledRenderUnitCapability.getResourceTypes().isEmpty()) {
- String[] resourceTypesRegistrationValue = new
String[bundledRenderUnitCapability.getResourceTypes().size()];
+ LinkedHashSet<String>
resourceTypesRegistrationValueSet = new LinkedHashSet<>();
int rtIndex = 0;
for (ResourceType resourceType :
bundledRenderUnitCapability.getResourceTypes()) {
- resourceTypesRegistrationValue[rtIndex++] =
resourceType.toString();
+
resourceTypesRegistrationValueSet.add(resourceType.toString());
}
+ String[] resourceTypesRegistrationValue =
resourceTypesRegistrationValueSet.stream().filter(rt -> {
+ if (!rt.startsWith("/")) {
+ for (String prefix :
resourceResolverFactory.getSearchPath()) {
+ if
(resourceTypesRegistrationValueSet.contains(prefix.concat(rt))) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }).toArray(String[]::new);
properties.put(ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES,
resourceTypesRegistrationValue);
String extension =
bundledRenderUnitCapability.getExtension();