[ 
https://issues.apache.org/jira/browse/LOG4J2-2948?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Volkan Yazici reassigned LOG4J2-2948:
-------------------------------------

    Assignee: Volkan Yazici

> Use IdentityHashMap for ParameterFormatter deja vu
> --------------------------------------------------
>
>                 Key: LOG4J2-2948
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2948
>             Project: Log4j 2
>          Issue Type: Improvement
>            Reporter: Marcono1234
>            Assignee: Volkan Yazici
>            Priority: Minor
>
> {{org.apache.logging.log4j.message.ParameterFormatter}} currently uses its 
> {{identityToString(Object)}} method to create identifier strings for 
> detecting recursive objects.
> However, as noted by the description of that method, this approach is not 
> completely foolproof:
> {code}
>      * As much as is reasonably practical, the hashCode method defined by
>      * class {@code Object} does return distinct integers for distinct
>      * objects. (This is typically implemented by converting the internal
>      * address of the object into an integer, but this implementation
>      * technique is not required by the Java™ programming language.)
> {code}
> Would it make sense to switch to JDK's 
> [{{java.util.IdentityHashMap}}|https://docs.oracle.com/javase/8/docs/api/java/util/IdentityHashMap.html]
>  (converted to {{Set}} using {{Collections.newSetFromMap}})? I would assume, 
> but have not tested it, that performance will also be better because it 
> simply tests for equality by checking for reference equality whereas the 
> current approach needs to compare strings.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to