You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2022/02/21 15:22:56 UTC

[GitHub] [logging-log4j2] ppkarwasz commented on a change in pull request #767: [LOG4J2-3410] Fix ClassCastException when key is not a string

ppkarwasz commented on a change in pull request #767:
URL: https://github.com/apache/logging-log4j2/pull/767#discussion_r811231397



##########
File path: log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
##########
@@ -309,15 +309,10 @@ private void fireRemoveAppenderEvent(final Appender appender) {
 
     public void forcedLog(final String fqcn, final Priority level, final Object message, final Throwable t) {
         final org.apache.logging.log4j.Level lvl = org.apache.logging.log4j.Level.toLevel(level.toString());
+        final Message msg = LegacyMessageFactory.INSTANCE.newMessage(message);
         if (logger instanceof ExtendedLogger) {
-            @SuppressWarnings("unchecked")
-            final Message msg = message instanceof Message ? (Message) message
-                : message instanceof Map ? new MapMessage((Map) message) : new ObjectMessage(message);
             ((ExtendedLogger) logger).logMessage(fqcn, lvl, null, msg, t);
         } else {
-            final ObjectRenderer renderer = get(message.getClass());
-            final Message msg = message instanceof Message ? (Message) message
-                : renderer != null ? new RenderedMessage(renderer, message) : new ObjectMessage(message);

Review comment:
       The `RenderedMessage` case is omitted, since this would require a stateful `MessageFactory` (per category).
   
   Anyway there is currently no way to add elements to the `RendererMap`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org