Skip to content

CAMEL-23906: Fix flaky DelayerWhileShutdownTest on JDK 25#24422

Merged
gnodet merged 2 commits into
mainfrom
camel-23906-fix-flaky-test-delayerwhileshutdownte
Jul 5, 2026
Merged

CAMEL-23906: Fix flaky DelayerWhileShutdownTest on JDK 25#24422
gnodet merged 2 commits into
mainfrom
camel-23906-fix-flaky-test-delayerwhileshutdownte

Conversation

@gnodet

@gnodet gnodet commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 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, causing testSendingMessageGetsDelayed to fail intermittently
  • The new approach uses a latch to signal when the short-delay route starts processing and increases the long delay to 30s to ensure context shutdown always interrupts it before completion

What changed

The original test used a Phaser(2) to synchronize both SEDA routes before they entered their delay phases, then immediately called assertMockEndpointsSatisfied(). On JDK 25, different thread scheduling could cause the short-delay message (1ms) to not have arrived at mock:result by the time of assertion.

The fix:

  1. Replaces Phaser with CountDownLatch — simpler synchronization; the latch signals when the short-delay route begins processing, with an assertion on the return value for fast failure if the route never starts
  2. Uses Awaitility.await() — replaces the direct assertMockEndpointsSatisfied() call with await().atMost(5, SECONDS).untilAsserted(...), making the assertion resilient to scheduling variations
  3. Increases long delay to 30000ms — well above the 5-second assertion timeout, ensuring the context shutdown always interrupts the long-delay route even under heavy CI load

Test plan

  • DelayerWhileShutdownTest passes consistently (verified multiple consecutive runs)
  • CI passes on JDK 17 and JDK 25

Claude Code on behalf of @oscerd

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 <noreply@anthropic.com>
@gnodet gnodet requested review from orpiske July 4, 2026 17:07
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions github-actions Bot added the core label Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • core/camel-core

🔬 Scalpel shadow comparison — Scalpel: 23 tested, 0 compile-only — current: 0 all tested

Maveniverse Scalpel detected 23 affected modules (current approach: 0).

⚠️ Modules only in Scalpel (23)
  • camel-console
  • camel-core
  • camel-csimple-joor
  • camel-datasonnet
  • camel-groovy
  • camel-hl7
  • camel-javascript
  • camel-joor
  • camel-jq
  • camel-jsonpath
  • camel-main
  • camel-management
  • camel-mvel
  • camel-ognl
  • camel-platform-http-jolokia
  • camel-python
  • camel-saxon
  • camel-spring-xml
  • camel-stax
  • camel-xml-io-dsl
  • camel-xml-jaxb-dsl
  • camel-xml-jaxb-dsl-test-definition
  • camel-xml-jaxb-dsl-test-spring

Skip-tests mode would test 23 modules (1 direct + 22 downstream), skip tests for 0 (generated code, meta-modules)

Modules Scalpel would test (23)
  • camel-console
  • camel-core
  • camel-csimple-joor
  • camel-datasonnet
  • camel-groovy
  • camel-hl7
  • camel-javascript
  • camel-joor
  • camel-jq
  • camel-jsonpath
  • camel-main
  • camel-management
  • camel-mvel
  • camel-ognl
  • camel-platform-http-jolokia
  • camel-python
  • camel-saxon
  • camel-spring-xml
  • camel-stax
  • camel-xml-io-dsl
  • camel-xml-jaxb-dsl
  • camel-xml-jaxb-dsl-test-definition
  • camel-xml-jaxb-dsl-test-spring

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • core/camel-core: 2 test(s) disabled on GitHub Actions
All tested modules (23 modules)
  • Camel :: Console
  • Camel :: Core
  • Camel :: DataSonnet
  • Camel :: Groovy
  • Camel :: HL7
  • Camel :: JQ
  • Camel :: JSon Path
  • Camel :: JavaScript
  • Camel :: MVEL
  • Camel :: Main
  • Camel :: Management
  • Camel :: OGNL (deprecated)
  • Camel :: Platform HTTP :: Jolokia
  • Camel :: Python
  • Camel :: Saxon
  • Camel :: Spring XML
  • Camel :: StAX
  • Camel :: XML DSL Jaxb :: Test :: Definition
  • Camel :: XML DSL Jaxb :: Test :: Spring
  • Camel :: XML DSL with camel-xml-io
  • Camel :: XML DSL with camel-xml-jaxb
  • Camel :: csimple jOOR (deprecated)
  • Camel :: jOOR

⚙️ View full build and test results

@gnodet gnodet marked this pull request as ready for review July 4, 2026 22:38
@gnodet gnodet requested a review from Copilot July 5, 2026 07:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates DelayerWhileShutdownTest to reduce flakiness (observed on newer JDK scheduling) by simplifying route synchronization and making the mock assertion tolerant of timing variations.

Changes:

  • Replace Phaser-based synchronization with a CountDownLatch signal.
  • Replace direct assertMockEndpointsSatisfied() with an Awaitility-based assertion window.
  • Adjust the “long delay” timing to widen the shutdown/interruption margin.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +44 to +46
// Wait until the short-delay route has entered the delay phase,
// ensuring both routes are actively processing
shortDelayStarted.await(5, TimeUnit.SECONDS);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ebe472b: the latch return value is now asserted with assertTrue() and a diagnostic message. Variable and comment also corrected.

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");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ebe472b: the long delay is now 30000ms (30s), well above the 5s Awaitility assertion timeout, eliminating this race.

- Assert that the CountDownLatch returns true, failing fast with a
  diagnostic message if the short-delay route never starts processing
- Increase the long delay from 5000ms to 30000ms so it is well above
  the 5-second Awaitility assertion timeout, eliminating the race
  where both could expire near the same instant under heavy CI load
- Fix comment and rename variable for clarity

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet requested review from davsclaus July 5, 2026 08:11
@gnodet gnodet added this to the 4.21 milestone Jul 5, 2026
@gnodet gnodet merged commit b419473 into main Jul 5, 2026
5 checks passed
@gnodet gnodet deleted the camel-23906-fix-flaky-test-delayerwhileshutdownte branch July 5, 2026 21:02
@gnodet gnodet modified the milestones: 4.21, 4.22.0 Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants