You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2026/07/04 17:06:58 UTC
(camel) 01/01: CAMEL-23906: Fix flaky DelayerWhileShutdownTest on JDK 25
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch camel-23906-fix-flaky-test-delayerwhileshutdownte
in repository https://gitbox.apache.org/repos/asf/camel.git
commit f1a46f6cb00ac2c99b2f1c922f681e08ec2bf2bd
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Sat Jul 4 17:06:33 2026 +0000
CAMEL-23906: Fix flaky DelayerWhileShutdownTest on JDK 25
Replace Phaser-based synchronization with a simpler CountDownLatch
and use Awaitility for the mock endpoint assertion. The Phaser approach
was timing-sensitive under JDK 25's thread scheduling. The new approach
uses a latch to signal when the short-delay route starts processing and
increases the long delay to 5000ms to ensure the context shutdown
always interrupts it before it completes.
Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
.../camel/processor/DelayerWhileShutdownTest.java | 27 +++++++++++-----------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/DelayerWhileShutdownTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/DelayerWhileShutdownTest.java
index 2c52c83febf2..cb732d95e0f4 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/DelayerWhileShutdownTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/DelayerWhileShutdownTest.java
@@ -16,44 +16,45 @@
*/
package org.apache.camel.processor;
-import java.util.concurrent.Phaser;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import static org.awaitility.Awaitility.await;
+
/**
* Delayer while shutting down so its interrupted and will also stop.
*/
public class DelayerWhileShutdownTest extends ContextTestSupport {
- private final Phaser phaser = new Phaser(2);
-
- @BeforeEach
- void sendEarly() {
- template.sendBody("seda:a", "Long delay");
- template.sendBody("seda:b", "Short delay");
- }
+ private final CountDownLatch shortDelayStarted = new CountDownLatch(1);
@Test
public void testSendingMessageGetsDelayed() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Short delay");
- phaser.awaitAdvanceInterruptibly(0, 5000, TimeUnit.SECONDS);
+ template.sendBody("seda:a", "Long delay");
+ template.sendBody("seda:b", "Short delay");
+
+ // Wait until the short-delay route has entered the delay phase,
+ // ensuring both routes are actively processing
+ shortDelayStarted.await(5, TimeUnit.SECONDS);
- assertMockEndpointsSatisfied();
+ await().atMost(5, TimeUnit.SECONDS)
+ .untilAsserted(() -> assertMockEndpointsSatisfied());
}
@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from("seda:a").process(e -> phaser.arriveAndAwaitAdvance()).delay(1000).to("mock:result");
- from("seda:b").process(e -> phaser.arriveAndAwaitAdvance()).delay(1).to("mock:result");
+ from("seda:a").delay(5000).to("mock:result");
+ from("seda:b").process(e -> shortDelayStarted.countDown()).delay(1).to("mock:result");
}
};
}