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

Gary D. Gregory resolved LOG4J2-3410.
-------------------------------------
    Fix Version/s: 2.17.2
       Resolution: Fixed

Hi [~bcfsham] ,

Thank you for reporting your issue. I fixed this in the {{release-2.x}} branch 
in git. Please try a local build or a snapshot build from 
[https://repository.apache.org/content/repositories/snapshots/]

It appears that the message logged might be a bit odd depending on the kind of 
{{Map}} logged. See the new test for details: 
{{/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerJira3410Test.java}}

> Log4j 1.2 bridge throws a ClassCastException when logging a Map with 
> non-String keys
> ------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-3410
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3410
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Log4j 1.2 bridge
>    Affects Versions: 2.13.0, 2.17.1
>         Environment: OS: Windows 10 Enterprise 64bit
> Java version: zulu8.31.0.1-jdk8.0.181-win_x64{*}{*}
>            Reporter: Barry Sham
>            Assignee: Gary D. Gregory
>            Priority: Major
>             Fix For: 2.17.2
>
>
> Our existing business logic contains a debug message which print out a 
> {_}org.apache.commons.collections.map.MultiKeyMap{_}:
>  
> {code:java}
> MultiKeyMap prnMap = MultiKeyMap.decorate(new LinkedMap());
> prnMap.put("0", "1", "2");
> logger.debug(prnMap);
> {code}
>  
> in {*}log4j-1.2-api 2.12.4{*}, it can be print out 
> {color:#4c9aff}properly{color}:
>  
> {code:java}
> {MultiKey[0, 1]=2}{code}
>  
> However it becomes an {color:#FF0000}ClassCastException {color}+since 
> *2.13.0* (including the latest {*}2.17.1{*})+
> {code:java}
> Exception in thread "main" java.lang.ClassCastException: 
> org.apache.commons.collections.keyvalue.MultiKey cannot be cast to 
> java.lang.String
>     at 
> org.apache.logging.log4j.util.SortedArrayStringMap.<init>(SortedArrayStringMap.java:154)
>     at org.apache.logging.log4j.message.MapMessage.<init>(MapMessage.java:125)
>     at org.apache.log4j.Category.maybeLog(Category.java:507)
>     at org.apache.log4j.Category.debug(Category.java:243)
>     at sideproject.sideproject.App.proeces(App.java:25)
>     at sideproject.sideproject.App.main(App.java:17){code}
> As the map can print out using *System.out* +without issue,+ we are wondering 
> if it is a bug in Apache Log4j 1.x Compatibility API
> A GitHub Project is prepared for reference: [shin779/log4j-multikeymap 
> (github.com)|https://github.com/shin779/log4j-multikeymap]



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to