You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by re...@apache.org on 2025/01/14 19:21:00 UTC
(sling-org-apache-sling-resourceresolver) 01/01: SLING-12619: Resource Resolver: MapEntries.loadVanityPath: use parameter instead of relying on object comparison
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch SLING-12619
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
commit 6ee040a0892f9f1b244848384e0f4b1d3c1d6bca
Author: Julian Reschke <re...@apache.org>
AuthorDate: Tue Jan 14 20:20:42 2025 +0100
SLING-12619: Resource Resolver: MapEntries.loadVanityPath: use parameter instead of relying on object comparison
---
.../sling/resourceresolver/impl/mapping/MapEntries.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
index e08cd6b..668b1ea 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
@@ -573,7 +573,7 @@ public class MapEntries implements
log.debug("doAddVanity getting {}", resource.getPath());
boolean updateTheCache = isAllVanityPathEntriesCached() || vanityCounter.longValue() < this.factory.getMaxCachedVanityPathEntries();
- return null != loadVanityPath(resource, resolveMapsMap, vanityTargets, updateTheCache);
+ return null != loadVanityPath(resource, resolveMapsMap, vanityTargets, updateTheCache, true);
}
private boolean doRemoveVanity(final String path) {
@@ -992,11 +992,11 @@ public class MapEntries implements
if ( isValid ) {
totalValid += 1;
if (this.vanityPathsProcessed.get() && (this.factory.isMaxCachedVanityPathEntriesStartup() || vanityCounter.longValue() < this.factory.getMaxCachedVanityPathEntries())) {
- loadVanityPath(resource, resolveMapsMap, vanityTargets, true);
+ loadVanityPath(resource, resolveMapsMap, vanityTargets, true, true);
entryMap = resolveMapsMap;
} else {
final Map <String, List<String>> targetPaths = new HashMap<>();
- loadVanityPath(resource, entryMap, targetPaths, true);
+ loadVanityPath(resource, entryMap, targetPaths, true, false);
}
}
}
@@ -1398,7 +1398,7 @@ public class MapEntries implements
countInScope += 1;
final boolean addToCache = isAllVanityPathEntriesCached()
|| vanityCounter.longValue() < this.factory.getMaxCachedVanityPathEntries();
- loadVanityPath(resource, resolveMapsMap, targetPaths, addToCache);
+ loadVanityPath(resource, resolveMapsMap, targetPaths, addToCache, true);
}
}
long processElapsed = System.nanoTime() - processStart;
@@ -1421,7 +1421,7 @@ public class MapEntries implements
*
* @return first vanity path or {@code null}
*/
- private String loadVanityPath(final Resource resource, final Map<String, List<MapEntry>> entryMap, final Map <String, List<String>> targetPaths, boolean addToCache) {
+ private String loadVanityPath(final Resource resource, final Map<String, List<MapEntry>> entryMap, final Map <String, List<String>> targetPaths, boolean addToCache, boolean updateCounter) {
if (!isValidVanityPath(resource.getPath())) {
return null;
@@ -1486,8 +1486,8 @@ public class MapEntries implements
if (addedEntry) {
// 3. keep the path to return
this.updateTargetPaths(targetPaths, redirect, checkPath);
- //increment only if the instance variable
- if (entryMap == resolveMapsMap) {
+
+ if (updateCounter) {
vanityCounter.addAndGet(2);
}