You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2022/02/21 15:29:00 UTC
[jira] [Assigned] (LOG4J2-3410) Log4j 1.2 bridge throws a ClassCastException when logging a Map with non-String keys
[ https://issues.apache.org/jira/browse/LOG4J2-3410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary D. Gregory reassigned LOG4J2-3410:
---------------------------------------
Assignee: Gary D. Gregory
> 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)