[ https://issues.apache.org/jira/browse/LOG4J2-2522?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Carter Kozak reassigned LOG4J2-2522: ------------------------------------ Assignee: Carter Kozak > Make MapMessageLookup.lookup usable with MapMessage again > --------------------------------------------------------- > > Key: LOG4J2-2522 > URL: https://issues.apache.org/jira/browse/LOG4J2-2522 > Project: Log4j 2 > Issue Type: Bug > Components: Core > Reporter: Adam Lesiak > Assignee: Carter Kozak > Priority: Minor > Fix For: 3.0.0, 2.11.2 > > Time Spent: 20m > Remaining Estimate: 0h > > https://issues.apache.org/jira/browse/LOG4J2-1935 > changed MapMessage to a generic superclass, > but decided to cast to StringMapMessage (a subclass with previous semantics) > in MapMessageLookup.lookup > Test case: > {{ @Test}} > {{ public void testEventMapMessage() {}} > {{ final HashMap<String, String> map = new HashMap<>();}} > {{ map.put("A", "B");}} > {{ final HashMap<String, String> eventMap = new HashMap<>();}} > {{ eventMap.put("A1", "B1");}} > {{ final StringMapMessage message = new StringMapMessage(eventMap);}} > {{ final LogEvent event = Log4jLogEvent.newBuilder()}} > {{ .setMessage(message)}} > {{ .build();}} > {{ final MapLookup lookup = new MapLookup(map);}} > {{ assertEquals("B", lookup.lookup(event, "A"));}} > {{ assertEquals("B1", lookup.lookup(event, "A1"));}} > {{ }}} > passes, but new test > {{ @Test}} > {{ public void testEventMapMessageNew() {}} > {{ final HashMap<String, String> map = new HashMap<>();}} > {{ map.put("A", "B");}} > {{ final HashMap<String, String> eventMap = new HashMap<>();}} > {{ eventMap.put("A1", 11);}} > {{ final MapMessage message = new MapMessage<>(eventMap);}} > {{ final LogEvent event = Log4jLogEvent.newBuilder()}} > {{ .setMessage(message)}} > {{ .build();}} > {{ final MapLookup lookup = new MapLookup(map);}} > {{ assertEquals("B", lookup.lookup(event, "A"));}} > {{ assertEquals("11", lookup.lookup(event, "A1"));}} > {{ }}} > Even worse, if we initialize MapMessage with a Map<String, String>, the test > case still fails. > -- This message was sent by Atlassian JIRA (v7.6.3#76005)