You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2016/11/29 07:33:59 UTC
[jira] [Comment Edited] (LOG4J2-1687) NPE in ThrowableProxy when
resolving stack
[ https://issues.apache.org/jira/browse/LOG4J2-1687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15704515#comment-15704515 ]
Gary Gregory edited comment on LOG4J2-1687 at 11/29/16 7:33 AM:
----------------------------------------------------------------
This is some funky special case. {{Object.getClass()}} returns null where the object is a {{ThrowableProxy}}? How is that possible? The Javadoc for {{Object.getClass()}} in Java 7 does not even hint that null is a legal return value. Have you tried using one of the {{LoaderUtil}} methods instead of {{this.getClass().getClassLoader().loadClass(className)}}?
was (Author: garydgregory):
This is some funky special case. {{Object.getClass()}} returns null where the object is a {{ThrowableProxy}}? How is that possible? The Javadoc for {{Object.getClass()}} in Java 7 does not even hint that null is a legal return value. Have you tried using one of the {{LoaderUtil}} methods?
> NPE in ThrowableProxy when resolving stack
> ------------------------------------------
>
> Key: LOG4J2-1687
> URL: https://issues.apache.org/jira/browse/LOG4J2-1687
> Project: Log4j 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.7
> Environment: - java version "1.7.0_80" ,Java(TM) SE Runtime Environment (build 1.7.0_80-b15), Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
> - Jboss EAP 5.2.0-EAP
> Reporter: Robert Christiansen
> Labels: easyfix
> Attachments: error.log, patch.diff
>
>
> NPE when logging in Java EE/OSGi environment.
> In some cases the ClassLoader ( https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getClassLoader() ) will be null for a Class.
> With the changes introduced in
> https://issues.apache.org/jira/browse/LOG4J2-1457 logging with %xEx can cause a NullPointerExeception when trying to resolve the stack.
> Since it's not a common occurrence in most environments I suggest the ThrowableProxy swallow the NPE in the same way it swallows SecurityExeception and other classloading exceptions to avoid extra branching for all environments.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org