apache / logging-log4j2

Apache Log4j 2 is a versatile, feature-rich, efficient logging API and backend for Java.
https://logging.apache.org/log4j/2.x/
Apache License 2.0
3.4k stars 1.62k forks source link

JeroMqAppenderTest is unreliable #3002

Closed garydgregory closed 1 month ago

garydgregory commented 1 month ago

Description

JeroMqAppenderTest is unreliable:

[ERROR] org.apache.logging.log4j.core.appender.mom.jeromq.JeroMqAppenderTest.testMultiThreadedServer(JeroMqAppender, LoggerContext) -- Time elapsed: 1.925 s <<< FAILURE!

Configuration

Version: 2.x at 01125b11a7c52af12204a1c4a646158f63b2d6eb

Operating system: Microsoft Windows [Version 10.0.19045.4780

JDK: Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937) Maven home: C:\java\apache-maven-3.9.9 Java version: 17.0.12, vendor: Eclipse Adoptium, runtime: C:\Program Files\Eclipse Adoptium\jdk-17.0.12.7-hotspot Default locale: en_US, platform encoding: UTF-8 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Logs

[ERROR] Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 7.051 s <<< FAILURE! -- in org.apache.logging.log4j.core.appender.mom.jeromq.JeroMqAppenderTest
[ERROR] org.apache.logging.log4j.core.appender.mom.jeromq.JeroMqAppenderTest.testMultiThreadedServer(JeroMqAppender, LoggerContext) -- Time elapsed: 1.925 s <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <20> but was: <19>
        at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
        at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
        at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
        at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:150)
        at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:145)
        at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:531)
        at org.apache.logging.log4j.core.appender.mom.jeromq.JeroMqAppenderTest.testMultiThreadedServer(JeroMqAppenderTest.java:136)
        at java.base/java.lang.reflect.Method.invoke(Method.java:569)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

Reproduction

mvn clean install
ppkarwasz commented 1 month ago

I have encountered this behavior a couple of times on the CI. If you look at the status log (which is dumped to stdout whenever the test fails), it shows that all 20 messages were delivered successfully.

What probably fails is:

https://github.com/apache/logging-log4j2/blob/be6dde2c5ff01dd8a70cf80dcaf95a38a355c9bc/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqAppenderTest.java#L136

which should be in a synchronized block, since the sendRcTrue variable it not volatile.

ppkarwasz commented 1 month ago

@garydgregory,

Can you check if you can reproduce the test failure with the #3033 fix?