kotlinx-lincheck icon indicating copy to clipboard operation
kotlinx-lincheck copied to clipboard

log4j2 incompatibility

Open btwilk opened this issue 3 years ago • 3 comments

lincheck version: 2.15 log4j version: 2.17.2

In my system under test I have

private val log: Logger = LogManager.getLogger("SystemUnderTestKt")

When I run a lincheck test I get

java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.util.PropertiesUtil
	at org.apache.logging.log4j.status.StatusLogger.<clinit>(StatusLogger.java:78)
	at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:61)
	at SystemUnderTestKt.<clinit>(SystemUnderTest.kt:17)
	at LinTest.<init>(LinTest.kt:111)

Ignoring log4j classes with .addGuarantee(forClasses(LogManager::class, Logger::class).allMethods().ignore()) doesn't help.

Non-lincheck unit tests for the system under test work fine.

btwilk avatar Nov 23 '22 23:11 btwilk

Hi @btwilk !

It seems log4j2 had this kind of problem before and the problem should have been fixed for your version. https://issues.apache.org/jira/browse/LOG4J2-2266

This happens because lincheck uses a custom classloader for byte-code transformation and log4j has a class that can not be loaded in this way. In general, we can not fix this. If a class can not be loaded with a custom classloader, then its byte-code can not be transformed.

ignore guarantee makes lincheck ignore what happens in the class, but does not remove method calls from byte-code. We can potentially make it not transform a class, but this will introduce new problems. For example, when a superclass A is transformed but the class B extends A itself is not, this will lead to a JVM failure when trying to do val a: A = B()

alefedor avatar Nov 24 '22 09:11 alefedor

We will eliminate custom class loaders in Lincheck, which should solve the issue.

ndkoval avatar Mar 02 '23 11:03 ndkoval

Hi, @btwilk! It has taken a while to address the issue, but the recent 2.30 release should've fixed it. Could you please check?

ndkoval avatar Apr 29 '24 18:04 ndkoval

@btwilk I'm closing this issue, as it should be fixed now. Please reopen it if you are still facing the bug.

ndkoval avatar Jun 27 '24 22:06 ndkoval