reschke commented on code in PR #152:
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/152#discussion_r1970093276


##########
src/main/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathHandler.java:
##########
@@ -222,30 +223,43 @@ private String getMapEntryRedirect(final MapEntry 
mapEntry) {
     }
 
     boolean doRemoveVanity(final String path) {
-        final String actualContentPath = getActualContentPath(path);
-        final List <String> l = vanityTargets.remove(actualContentPath);
-        if (l != null){
-            for (final String s : l){
-                final List<MapEntry> entries = this.resolveMapsMap.get(s);
-                if (entries!= null) {
-                    for (final Iterator<MapEntry> iterator = 
entries.iterator(); iterator.hasNext(); ) {
-                        final MapEntry entry = iterator.next();
-                        final String redirect = getMapEntryRedirect(entry);
-                        if (redirect != null && 
redirect.equals(actualContentPath)) {
-                            iterator.remove();
-                        }
-                    }
+        String actualContentPath = getActualContentPath(path);
+        List<String> targets = this.vanityTargets.remove(actualContentPath);
+
+        if (targets != null) {
+            for (String target : targets) {
+                int count = removeEntriesFromResolvesMap(target, 
actualContentPath);
+                if (vanityCounter.longValue() >= count) {
+                    vanityCounter.addAndGet(-count);

Review Comment:
   There was an assumption throughout the code that the # of cache entries per 
vanity path always is 2. That is an implementation detail, and I tried - 
hopefully successfully - to return and use the actual number of 
additions/removals. Note that this (IMHO) only affects that counter, so it 
probably does not matter at all.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to