You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Volkan Yazici (Jira)" <ji...@apache.org> on 2021/03/04 12:29:00 UTC

[jira] [Resolved] (LOG4J2-2948) Use IdentityHashMap for ParameterFormatter deja vu

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

Volkan Yazici resolved LOG4J2-2948.
-----------------------------------
    Resolution: Fixed

> 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
>             Fix For: 2.14.1
>
>
> {{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&#8482; 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)