[ https://issues.apache.org/jira/browse/LOG4J2-3410?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17495617#comment-17495617 ]
ASF subversion and git services commented on LOG4J2-3410: --------------------------------------------------------- Commit 51da8e2a50a841bbe1aafe929e3ef29d2f3aa1f2 in logging-log4j2's branch refs/heads/release-2.x from Gary Gregory [ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=51da8e2 ] [LOG4J2-3410] Log4j 1.2 bridge throws a ClassCastException when logging a Map with non-String keys. > 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 > > 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)