This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 8acb69ef999a CAMEL-27281: camel-quartz - attach the WARN capture of
the tests once log4j has started (#30866)
8acb69ef999a is described below
commit 8acb69ef999a2b4c30ea4376d6ba11c008444345
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Nov 26 13:57:52 2026 +0100
CAMEL-27281: camel-quartz - attach the WARN capture of the tests once log4j
has started (#30866)
QuartzInjectedSchedulerTest and QuartzIgnoredPropertiesFileWarningTest
attach
an appender to the QuartzComponent logger. The test classes run in parallel:
when another class is still starting log4j, the logger has the default
configuration, and the appender attached to it is stopped and lost when
log4j
swaps in log4j2.properties (the diagnostics of the failure on CI show
exactly
that: appender stopped and detached, logger on the root config). The tests
now
wait until the LoggerContext has started before they attach the appender.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Claus Ibsen <[email protected]>
---
.../component/quartz/QuartzIgnoredPropertiesFileWarningTest.java | 8 ++++++++
.../camel/component/quartz/QuartzInjectedSchedulerTest.java | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git
a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzIgnoredPropertiesFileWarningTest.java
b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzIgnoredPropertiesFileWarningTest.java
index 8b5e995f1925..ff336a8db73d 100644
---
a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzIgnoredPropertiesFileWarningTest.java
+++
b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzIgnoredPropertiesFileWarningTest.java
@@ -23,6 +23,7 @@ import java.nio.file.Path;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
import org.apache.camel.test.junit6.CamelTestSupport;
import org.apache.camel.test.junit6.TestExecutionConfiguration;
@@ -30,6 +31,7 @@ import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.logging.log4j.core.config.Property;
import org.junit.jupiter.api.AfterEach;
@@ -40,6 +42,7 @@ import org.junit.jupiter.api.parallel.Isolated;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;
+import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
@@ -78,6 +81,11 @@ class QuartzIgnoredPropertiesFileWarningTest extends
CamelTestSupport {
@BeforeEach
void captureWarnings() {
+ // the test classes run in parallel: while another one is still
starting log4j, the logger has the default
+ // configuration, which log4j replaces once it has read
log4j2.properties, and the appender attached to it is
+ // stopped and lost (CAMEL-27281), so attach it once log4j has started
+ LoggerContext logging = componentLogger().getContext();
+ await().atMost(30, TimeUnit.SECONDS).until(logging::isStarted);
appender.start();
componentLogger().addAppender(appender);
// addAppender creates a non-additive logger config, which would hide
this logger from the root appenders
diff --git
a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzInjectedSchedulerTest.java
b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzInjectedSchedulerTest.java
index 7b679522078d..3c6395ce4132 100644
---
a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzInjectedSchedulerTest.java
+++
b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzInjectedSchedulerTest.java
@@ -35,6 +35,7 @@ import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.logging.log4j.core.config.Property;
import org.junit.jupiter.api.AfterEach;
@@ -89,6 +90,11 @@ class QuartzInjectedSchedulerTest extends CamelTestSupport {
@BeforeEach
void captureWarnings() {
+ // the test classes run in parallel: while another one is still
starting log4j, the logger has the default
+ // configuration, which log4j replaces once it has read
log4j2.properties, and the appender attached to it is
+ // stopped and lost (CAMEL-27281), so attach it once log4j has started
+ LoggerContext logging = componentLogger().getContext();
+ await().atMost(30, TimeUnit.SECONDS).until(logging::isStarted);
appender.start();
componentLogger().addAppender(appender);
// addAppender creates a non-additive logger config, which would hide
this logger from the root appenders
@@ -261,6 +267,8 @@ class QuartzInjectedSchedulerTest extends CamelTestSupport {
+ ", loggerConfig=" + logger.get().getName()
+ ", additive=" + logger.isAdditive()
+ ", warnEnabled=" + logger.isWarnEnabled()
+ + ", loggingStarted=" + logger.getContext().isStarted()
+ + ", loggingConfiguration=" +
logger.getContext().getConfiguration().getClass().getSimpleName()
+ ", quartzComponentStatus=" + quartzComponentStatus()
+ ", thread=" + Thread.currentThread().getName();
}