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/02/06 19:02:06 UTC

(sling-org-apache-sling-resourceresolver) branch SLING-12648 updated (386a050 -> b807bbd)

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

reschke pushed a change to branch SLING-12648
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git


    from 386a050  SLING-12648: MapEntries: factor out vanity path handling - move vanityTargets
     new 6fd0fb5  SLING-12648: MapEntries: factor out vanity path handling - move vanityTargets
     new b807bbd  SLING-12648: MapEntries: factor out vanity path handling - move NO_MAP_ENTRIES

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../sling/resourceresolver/impl/mapping/MapEntries.java       | 11 ++++++-----
 .../impl/mapping/VanityPathMapEntriesTest.java                |  7 +++++--
 2 files changed, 11 insertions(+), 7 deletions(-)


(sling-org-apache-sling-resourceresolver) 02/02: SLING-12648: MapEntries: factor out vanity path handling - move NO_MAP_ENTRIES

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reschke pushed a commit to branch SLING-12648
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git

commit b807bbd6082bd36b1f0b5a1300d14f5f93c36607
Author: Julian Reschke <re...@apache.org>
AuthorDate: Thu Feb 6 20:01:58 2025 +0100

    SLING-12648: MapEntries: factor out vanity path handling - move NO_MAP_ENTRIES
---
 .../sling/resourceresolver/impl/mapping/MapEntries.java       | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 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 76fd32e..f225123 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
@@ -622,9 +622,6 @@ public class MapEntries implements
         return vph.getVanityPathMappings();
     }
 
-    // special singleton entry for negative cache entries
-    private static final List<MapEntry> NO_MAP_ENTRIES = Collections.emptyList();
-
     /**
      * Refresh the resource resolver if not already done
      * @param resolverRefreshed Boolean flag containing the state if the resolver
@@ -1160,6 +1157,7 @@ public class MapEntries implements
     private static final int VANITY_BLOOM_FILTER_MAX_ENTRIES = 10000000;
 
     private final AtomicLong vanityCounter = new AtomicLong(0);
+
     private final AtomicLong vanityResourcesOnStartup = new AtomicLong(0);
     private final AtomicLong vanityPathLookups = new AtomicLong(0);
     private final AtomicLong vanityPathBloomNegatives = new AtomicLong(0);
@@ -1174,6 +1172,9 @@ public class MapEntries implements
 
     private Map <String,List <String>> vanityTargets = Collections.emptyMap();
 
+    // special singleton entry for negative cache entries
+    private final List<MapEntry> noMapEntries = Collections.emptyList();
+
     // Temporary cache for use while doing async vanity path query
     private Map<String, List<MapEntry>> temporaryResolveMapsMap;
 
@@ -1389,7 +1390,7 @@ public class MapEntries implements
                     mapEntries = mapEntry.get(vanityPath);
                     if (!initFinished && temporaryResolveMapsMap != null) {
                         log.trace("getMapEntryList: caching map entries for {} -> {}", vanityPath, mapEntries);
-                        temporaryResolveMapsMap.put(vanityPath, mapEntries == null ? NO_MAP_ENTRIES : mapEntries);
+                        temporaryResolveMapsMap.put(vanityPath, mapEntries == null ? noMapEntries : mapEntries);
                     }
                 }
             }
@@ -1399,7 +1400,7 @@ public class MapEntries implements
             }
         }
 
-        return mapEntries == NO_MAP_ENTRIES ? null : mapEntries;
+        return mapEntries == noMapEntries ? null : mapEntries;
     }
 
     private byte[] createVanityBloomFilter() throws IOException {


(sling-org-apache-sling-resourceresolver) 01/02: SLING-12648: MapEntries: factor out vanity path handling - move vanityTargets

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reschke pushed a commit to branch SLING-12648
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git

commit 6fd0fb569b7ba6ebab4e27447c3503f2f95e7ad6
Author: Julian Reschke <re...@apache.org>
AuthorDate: Thu Feb 6 19:37:51 2025 +0100

    SLING-12648: MapEntries: factor out vanity path handling - move vanityTargets
---
 .../resourceresolver/impl/mapping/VanityPathMapEntriesTest.java    | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
index 4be59a4..8905f0c 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
@@ -174,8 +174,11 @@ public class VanityPathMapEntriesTest extends AbstractMappingMapEntriesTest {
         return (AtomicLong) vanityCounter.get(mapEntries.vph);
     }
 
-    private static Map<String, List<String>> getVanityTargets(MapEntries mapEntries) {
-        return mapEntries.vph.getVanityPathMappings();
+    @SuppressWarnings("unchecked")
+    private static Map<String, List<String>> getVanityTargets(MapEntries mapEntries) throws NoSuchFieldException, IllegalAccessException {
+        Field field = MapEntries.VanityPathHandler.class.getDeclaredField("vanityTargets");
+        field.setAccessible(true);
+        return (Map<String, List<String>>) field.get(mapEntries.vph);
     }
 
     @SuppressWarnings("unchecked")