Hey,
I just stumbled across a silly issue. If I have log4j2 in the classpath, and put specific loggers on debug, the system crashes.
Reproduction should be simple:
- Create a project
- add luaj 3.0.1 to the classpath
- add log4j2-core version 2.6.2 to the classpath
- add log4j2-api version 2.6.2 to the classpath
- create a small log4j2.xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="DEBUG">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
Create a java class as follows:
import org.apache.logging.log4j.LogManager;
public class LuaCrashRepro {
public static void main(String[] args) {
LogManager.getLogger("A");
}
}
This will result in a crash as follows:
Exception in thread "main" java.lang.NullPointerException
at org.luaj.vm2.script.LuaScriptEngineFactory.getParameter(Unknown Source)
at org.apache.logging.log4j.core.script.ScriptManager.<init>(ScriptManager.java:62)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:201)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:231)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:496)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:566)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:582)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:217)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:242)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:618)
at org.subquark.engine.LuaCrashRepro.main(LuaCrashRepro.java:7)
As far as I can see, the problem is rather simple:
I think the best fix here would be to use Objects.toString in getParameter, if don't need to support Java 7.
Regards,
Tetha
we are facing the same issue. is there any resolution to this?