You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2023/02/16 13:26:54 UTC
[sling-org-apache-sling-resourcemerger] branch master updated: SLING-11776 : Sling ResourceMerger may cause high cpu utilizations. Patch provided by Sagar Miglani (saga@adobe.com)
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcemerger.git
The following commit(s) were added to refs/heads/master by this push:
new 043fb8a SLING-11776 : Sling ResourceMerger may cause high cpu utilizations. Patch provided by Sagar Miglani (saga@adobe.com)
043fb8a is described below
commit 043fb8a7ee8194e7b1adab840f603a9da9892bf5
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Feb 16 14:26:41 2023 +0100
SLING-11776 : Sling ResourceMerger may cause high cpu utilizations. Patch provided by Sagar Miglani (saga@adobe.com)
---
.../sling/resourcemerger/impl/MergingResourceProvider.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/main/java/org/apache/sling/resourcemerger/impl/MergingResourceProvider.java b/src/main/java/org/apache/sling/resourcemerger/impl/MergingResourceProvider.java
index 5e03120..a0364fb 100644
--- a/src/main/java/org/apache/sling/resourcemerger/impl/MergingResourceProvider.java
+++ b/src/main/java/org/apache/sling/resourcemerger/impl/MergingResourceProvider.java
@@ -30,6 +30,8 @@ import org.apache.sling.resourcemerger.spi.MergedResourcePicker2;
import org.apache.sling.spi.resource.provider.ResolveContext;
import org.apache.sling.spi.resource.provider.ResourceContext;
import org.apache.sling.spi.resource.provider.ResourceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class MergingResourceProvider extends ResourceProvider<Void> {
@@ -41,6 +43,8 @@ public class MergingResourceProvider extends ResourceProvider<Void> {
protected final boolean traverseHierarchie;
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
MergingResourceProvider(final String mergeRootPath,
final MergedResourcePicker2 picker,
final boolean readOnly,
@@ -163,7 +167,16 @@ public class MergingResourceProvider extends ResourceProvider<Void> {
*/
protected String getRelativePath(String path) {
if (path.startsWith(mergeRootPath)) {
+
path = path.substring(mergeRootPath.length());
+
+ // multiple merge root paths at beginning should not be expected
+ // and can cause high cpu utilization, see SLING-11776
+ if (path.startsWith(mergeRootPath)) {
+ logger.debug("Multiple merge root path {} found at beginning of path {}", mergeRootPath, path);
+ return null;
+ }
+
if (path.length() == 0) {
return path;
} else if (path.charAt(0) == '/') {