You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Andre Elis (Jira)" <ji...@apache.org> on 2020/03/21 22:04:00 UTC
[jira] [Commented] (LOG4J2-2809) java.lang.NullPointerException at
java9 org.apache.logging.log4j.util.StackLocator.calcLocation()
[ https://issues.apache.org/jira/browse/LOG4J2-2809?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17064078#comment-17064078 ]
Andre Elis commented on LOG4J2-2809:
------------------------------------
Stack trace for clarity:
{code:java}
// java.lang.NullPointerException: null
at org.apache.logging.log4j.util.StackLocator.calcLocation(StackLocator.java:79) ~[log4j-api-2.13.1.jar:2.13.1]
at org.apache.logging.log4j.util.StackLocatorUtil.calcLocation(StackLocatorUtil.java:78) ~[log4j-api-2.13.1.jar:2.13.1]
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:409) ~[log4j-core-2.13.1.jar:2.13.1]
at org.apache.logging.log4j.core.config.DefaultReliabilityStrategy.log(DefaultReliabilityStrategy.java:49) ~[log4j-core-2.13.1.jar:2.13.1]
at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:153) ~[log4j-core-2.13.1.jar:2.13.1]
at org.apache.log4j.Category.forcedLog(Category.java:388) ~[log4j-1.2-api-2.13.1.jar:2.13.1]
at org.apache.log4j.Category.log(Category.java:499) ~[log4j-1.2-api-2.13.1.jar:2.13.1]
{code}
> java.lang.NullPointerException at java9 org.apache.logging.log4j.util.StackLocator.calcLocation()
> --------------------------------------------------------------------------------------------------
>
> Key: LOG4J2-2809
> URL: https://issues.apache.org/jira/browse/LOG4J2-2809
> Project: Log4j 2
> Issue Type: Bug
> Reporter: Andre Elis
> Priority: Major
>
> When log() is called from a class using an instance created/stored at ThreadLocal
> its StackWalker.StackFrame names changes to "WrappingClass$ClassFromThreadLocal".
> This causes to throw NPE because walker.walk(LOCATOR) returns null.
> {code:java}
> // StackTraceElement element = walker.walk(LOCATOR).toStackTraceElement();
> {code}
> It is suggested to check the result of walk() for null-ness and react in the way different from NPE.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)