[
https://issues.apache.org/jira/browse/LOG4J2-3410?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17495819#comment-17495819
]
Barry Sham commented on LOG4J2-3410:
------------------------------------
Dear [~ggregory] and [~ppkarwasz],
We updated our testing repo to test MultiKeyMap with nested objects including
null value:
[shin779/log4j-multikeymap
(github.com)|https://github.com/shin779/log4j-multikeymap]
With combination of 2.17.2 snapshots below:
* log4j-1.2-api-2.17.2-20220221.163807-124.jar
* log4j-api-2.17.2-20220221.163807-115.jar
* log4j-core-2.17.2-20220221.163807-112.jar
It is confirmed the out debug message can be logged without Exception.
We will keep track the status and update our library after the change released.
Thanks for making the world better.
> 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)