Bob created IGNITE-17462:
----------------------------

             Summary: Use of reflection to load NullAppender causes 
NullPointerException when NullAppender is removed
                 Key: IGNITE-17462
                 URL: https://issues.apache.org/jira/browse/IGNITE-17462
             Project: Ignite
          Issue Type: Bug
          Components: general
    Affects Versions: 2.13
            Reporter: Bob


When using log4j 2.17, the use of Java reflection to create the NullAppender 
instance during node start causes the NullAppender to be created with 
NullAppender.name=null. Later during node start, when the NullAppender is being 
removed, a NullPointerException occurs because of the null name. While log4j 
2.18 changed the code slightly to prevent the NPE from occurring, the side 
effect is that the NullAppender never actually gets removed.

Line 8983 of 
/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java does the 
following:

                nullApp = 
Class.forName("org.apache.log4j.varia.NullAppender").newInstance();

This creates the NullAppender with name=null. The documentaion for NullAppender 
states it should be created with NullAppender.createAppender(), which will make 
sure name is not null, which will in turn make it possible to remove the 
NullAppender later on. It also states it should NOT be created with new 
NullAppender(), which is what happens when newInstance() is called.

This issue is causing some pain to avoid the NPEs when running alongside Spark 
3.3, which pulls in Log4j 2.17.2. Basically, the only way to get this 
environment to work is to make sure none of the Log4j v1 classes are present in 
the classpath, including those provided by the log4j-1.2-api jar that gets 
bundled with log4j-api and log4j-core.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to