Skip to content

CAMEL-23893: Fix flaky SpringFileWatcherTest.testDefaultConfig on JDK 25#24403

Merged
gnodet merged 1 commit into
apache:mainfrom
gnodet:fix-flaky-test-in-camel-file-watch-on-jdk-25-the
Jul 3, 2026
Merged

CAMEL-23893: Fix flaky SpringFileWatcherTest.testDefaultConfig on JDK 25#24403
gnodet merged 1 commit into
apache:mainfrom
gnodet:fix-flaky-test-in-camel-file-watch-on-jdk-25-the

Conversation

@gnodet

@gnodet gnodet commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix flaky SpringFileWatcherTest.testDefaultConfig in camel-file-watch that fails on JDK 25 but passes on JDK 17.

Root cause: JDK 25's WatchService initializes faster than JDK 17's, causing it to deliver a CREATE event for the file created in @BeforeEach. This produces 3 events (1 CREATE + 2 MODIFY) instead of the expected 2 (2 MODIFY only).

Fix:

  • Changed setExpectedCount(2) to expectedMinimumMessageCount(2) to tolerate the extra CREATE event while still verifying that both MODIFY events are delivered
  • Replaced Thread.sleep(50) with Awaitility to reliably wait for the watcher to process and hash the first write before the second (per project coding standards)
  • Increased setResultWaitTime to 2000ms for CI robustness

JIRA: CAMEL-23893

Test plan

  • SpringFileWatcherTest.testDefaultConfig passes on JDK 17
  • SpringFileWatcherTest.testDefaultConfig passes on JDK 25
  • SpringFileWatcherTest.testCustomHasher passes on both JDKs
  • CI green on both JDK 17 and JDK 25 builds

🤖 Generated with Claude Code on behalf of @gnodet

On JDK 25, the WatchService initializes faster and delivers CREATE
events from file creation in @beforeeach, causing testDefaultConfig to
receive 3 events (1 CREATE + 2 MODIFY) instead of the expected 2.

Changes:
- Use expectedMinimumMessageCount(2) instead of exact count to tolerate
  CREATE events from @beforeeach file creation on JDK 25+
- Replace Thread.sleep(50) with Awaitility to wait for the watcher to
  process and hash the first write before the second one
- Increase result wait time from 1s to 2s for CI robustness

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet requested review from davsclaus July 3, 2026 10:10
@github-actions

github-actions Bot commented Jul 3, 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 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-file-watch

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

Maveniverse Scalpel detected 1 affected modules (current approach: 9).

Modules only in current approach (8)
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin

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

Modules Scalpel would test (1)
  • camel-file-watch

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

All tested modules (9 modules)
  • Camel :: File Watch
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Launcher :: Container
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@gnodet gnodet changed the title Fix flaky SpringFileWatcherTest on JDK 25 CAMEL-23893: Fix flaky SpringFileWatcherTest.testDefaultConfig on JDK 25 Jul 3, 2026
@gnodet gnodet merged commit e487881 into apache:main Jul 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants