Closed nik9000 closed 2 years ago
Pinging @elastic/es-core-infra (Team:Core/Infra)
REPRODUCE WITH: ./gradlew ':server:test' --tests "org.elasticsearch.common.logging.LoggersTests.testParameterizedMessageLambda {seed=[63C538FEBB285B59:C4E38DE6C5C14243]}" -Dtests.seed=63C538FEBB285B59 -Dtests.locale=ar-LY -Dtests.timezone=America/Catamarca -Druntime.java=17
2> java.lang.NullPointerException: Cannot invoke "org.apache.logging.log4j.core.LogEvent.getLevel()" because "appender.lastEvent" is null
at __randomizedtesting.SeedInfo.seed([63C538FEBB285B59:C4E38DE6C5C14243]:0)
at org.elasticsearch.common.logging.LoggersTests.testParameterizedMessageLambda(LoggersTests.java:36)
This only happens when the test is executed twice (or more)
I think this is because there is only one Logger instance (cached by log4j). On the first run it adds a new instance of the appender and asserts about this. On the second instance it adds another instance of an appender under the same name. Which won't be added to a logger - an appender with that name was already set (AbstractConfiguration#addAppender). the test in the second run will try to assert about the second appender instance (which is not set on a logger).
we can easily fix this by a different unique name of the appender per run. But is this really a problem? What make you to run this test twice @nik9000 ? :)
Repro line:
Reproduces locally?: yes
Applicable branches: master, more?