[jboss-jira] [JBoss JIRA] (LOGMGR-266) log4j2-jboss-logmanager LevelTranslator NullPointer
James Perkins (Jira)
issues at jboss.org
Mon Mar 16 11:07:49 EDT 2020
[ https://issues.redhat.com/browse/LOGMGR-266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13999878#comment-13999878 ]
James Perkins commented on LOGMGR-266:
--------------------------------------
Good catch. I wasn't aware the level could be {{null}}. I've created https://github.com/jboss-logging/log4j2-jboss-logmanager/issues/3 for this as well. I'll leave this open for now as a reminder.
> log4j2-jboss-logmanager LevelTranslator NullPointer
> ---------------------------------------------------
>
> Key: LOGMGR-266
> URL: https://issues.redhat.com/browse/LOGMGR-266
> Project: JBoss Log Manager
> Issue Type: Bug
> Reporter: Boris Unckel
> Priority: Critical
>
> We found the following Nullpointer Exception
> {code}
> Caused by: java.lang.NullPointerException
> at org.jboss.logmanager.log4j.LevelTranslator.translateLevel(LevelTranslator.java:95)
> at org.jboss.logmanager.log4j.JBossLogger.getLevel(JBossLogger.java:156)
> {code}
> ....
> Reason seems that LevelTranslator is not defensive enough. Suggestion:
> {code}
> java.util.logging.Level translateLevel(final Level level) {
> //level null is same as level not translated
> if(level == null) {
> return org.jboss.logmanager.Level.INFO;
> }
> final java.util.logging.Level result = log4jToJul.get(level.intLevel());
> return result == null ? org.jboss.logmanager.Level.INFO : result;
> }
> Level translateLevel(final java.util.logging.Level level) {
> //level null is same as level not translated
> if(level == null) {
> return Level.INFO;
> }
> final Level result = julToLog4j.get(level.intValue());
> return result == null ? Level.INFO : result;
> }
> {code}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
More information about the jboss-jira
mailing list