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


##########
src/main/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathHandler.java:
##########
@@ -630,23 +630,23 @@ private boolean addEntry(final Map<String, 
List<MapEntry>> entryMap, final Strin
             return false;
         } else {
             List<MapEntry> entries = entryMap.get(key);
-            if (entries == null) {
-                entries = new ArrayList<>();
-                entries.add(entry);
-                entryMap.put(key, entries);
-            } else {
-                List<MapEntry> entriesCopy = new ArrayList<>(entries);
-                entriesCopy.add(entry);
-                // and finally sort list
-                Collections.sort(entriesCopy);
-                entryMap.put(key, entriesCopy);
-                int size = entriesCopy.size();
-                if (size == 10) {
-                    log.debug(">= 10 MapEntries for {} - check your 
configuration", key);
-                } else if (size == 100) {
-                    log.info(">= 100 MapEntries for {} - check your 
configuration", key);
-                }
+
+            // copy existing list contents (when not empty), add new entry, 
then sort
+            List<MapEntry> entriesCopy = new ArrayList<>(entries != null ? 
entries : List.of());
+            entriesCopy.add(entry);
+            Collections.sort(entriesCopy);
+
+            // update map with new list
+            entryMap.put(key, entriesCopy);
+
+            // warn when list of entries for one key grows
+            int size = entriesCopy.size();
+            if (size == 10) {
+                log.debug(">= 10 MapEntries for {} - check your 
configuration", key);

Review Comment:
   It's actually " == 10" entries, not ">= 10" :-)



-- 
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