You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2021/03/01 19:57:20 UTC

[GitHub] [logging-log4j2] carterkozak commented on a change in pull request #471: LOG4J2-2948 Replace HashSet with IdentityHashMap in ParameterFormatter to detect cycles.

carterkozak commented on a change in pull request #471:
URL: https://github.com/apache/logging-log4j2/pull/471#discussion_r585008161



##########
File path: log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterFormatter.java
##########
@@ -538,24 +536,28 @@ private static void appendArray(final Object o, final StringBuilder str, Set<Str
                     } else {
                         str.append(", ");
                     }
-                    recursiveDeepToString(current, str, new HashSet<>(dejaVu));
+                    recursiveDeepToString(current, str, effectiveDejaVu);

Review comment:
       By removing the `new HashSet` as we traverse the collection, I think we end up producing potentially confusing data. I think we may want to keep the collection creation despite the additional allocation cost.
   
   We should add tests for this case ;-)
   
   Consider `[Foo{A}, Foo{A}]`. It duplicates data, however it's not recursive. We only want to catch cycles here, not duplication, e.g. `A=[Foo{delegate=A}]` if that makes sense. What do you think? 




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org