You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2016/09/18 10:41:21 UTC

[jira] [Closed] (LOG4J2-1415) Avoid calling toString() on auto-boxed primitive message parameters

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

Remko Popma closed LOG4J2-1415.
-------------------------------
    Resolution: Fixed

> Avoid calling toString() on auto-boxed primitive message parameters
> -------------------------------------------------------------------
>
>                 Key: LOG4J2-1415
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1415
>             Project: Log4j 2
>          Issue Type: Improvement
>    Affects Versions: 2.6
>            Reporter: Anthony Maire
>            Assignee: Remko Popma
>            Priority: Minor
>             Fix For: 2.6.2
>
>
> When using Log4j 2 through the SLF4J binding, the Unboxer mecanism is not available and a parameterized message with a primitive type parameter will be auto-boxed.
> Then this boxed value will be formatted by ParameterFormatter.recursiveDeepToString() and further allocations will happen
> To lower allocation rate for SLF4J users, ParameterFormatter.appendSpecialTypes() should handle boxed primitive types too.
> {code}
> private static boolean appendSpecialTypes(final Object o, final StringBuilder str) {
>     ...
>     } else if (o instanceof Long) {
>         str.append(((Long) o).longValue());
>         return true;
>     } else if (o instanceof Integer) {
>         str.append(((Integer) o).intValue());
>         return true;
>     } else if (o instanceof Double) {
>         str.append(((Double) o).doubleValue());
>         return true;
>     } // similarly for float, short, boolean and char.
>     ...
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org