Skip to content

CAMEL-23921: Replace Thread.sleep with Awaitility in SFTP tests#24603

Merged
davsclaus merged 1 commit into
apache:mainfrom
gnodet:fix/CAMEL-23921-replace-thread-sleep
Jul 11, 2026
Merged

CAMEL-23921: Replace Thread.sleep with Awaitility in SFTP tests#24603
davsclaus merged 1 commit into
apache:mainfrom
gnodet:fix/CAMEL-23921-replace-thread-sleep

Conversation

@gnodet

@gnodet gnodet commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Claude Code on behalf of @gnodet

Summary

Replaces all Thread.sleep() calls in three camel-mina-sftp integration test classes with proper condition-based waiting, per project guidelines.

  • MinaSftpAdvancedFileOperationsIT: 3x Thread.sleep(500)Awaitility.await().untilAsserted(...) for filesystem move verification after mock.assertIsSatisfied()
  • MinaSftpProtocolIT: 2x Thread.sleep(1000)Awaitility.await().untilAsserted(...) for filesystem delete/move; 1x Thread.sleep(2000) → explicit file.setLastModified() (no delay needed)
  • MinaSftpConcurrencyIT: 2x Thread.sleep(50/100) removed — these were unnecessary pacing delays in concurrent threads that don't affect correctness

Important: The Awaitility calls wrap only the filesystem assertions (file exists, file deleted, file moved) — they do NOT wrap MockEndpoint.assertIsSatisfied(), which already waits internally via CountDownLatch.

Changed files

File Change
MinaSftpAdvancedFileOperationsIT.java 3x sleep → Awaitility for post-move checks
MinaSftpProtocolIT.java 2x sleep → Awaitility for post-delete/move; 1x sleep → setLastModified()
MinaSftpConcurrencyIT.java 2x pacing sleeps removed

Test plan

  • Compilation passes
  • Formatting validation passes (formatter:validate, impsort:check)
  • CI build passes

🤖 Generated with Claude Code

- MinaSftpAdvancedFileOperationsIT: replace 3x Thread.sleep(500) after
  mock assertions with Awaitility to wait for filesystem move operations
- MinaSftpProtocolIT: replace 2x Thread.sleep(1000) after mock
  assertions with Awaitility for file delete/move; replace
  Thread.sleep(2000) timestamp gap with explicit setLastModified()
- MinaSftpConcurrencyIT: remove 2x unnecessary pacing delays
  (Thread.sleep(50/100)) in concurrent read/write test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet requested review from davsclaus and oscerd July 11, 2026 16:59
@github-actions

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

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-mina-sftp

🔬 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-mina-sftp

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

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

⚙️ View full build and test results

@gnodet gnodet marked this pull request as ready for review July 11, 2026 17:46

@gnodet gnodet left a comment

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.

Claude Code self-review on behalf of @gnodet

LGTM — clean Thread.sleep→Awaitility migration, follows project guidelines exactly.

Review

All three changes are correct:

  1. MinaSftpAdvancedFileOperationsIT — 3x Thread.sleep(500)Awaitility.await().atMost(10, SECONDS).untilAsserted(...) for post-move filesystem checks. Correct — these wrap filesystem state assertions, not MockEndpoint.

  2. MinaSftpProtocolIT — 2x Thread.sleep(1000) → Awaitility for file delete/move; 1x Thread.sleep(2000)setLastModified() to create a past timestamp instead of sleeping for clock drift. The setLastModified approach is elegant — eliminates the delay entirely.

  3. MinaSftpConcurrencyIT — 2x pacing sleeps (50ms/100ms) removed from concurrent read/write threads. These were unnecessary for correctness.

Checklist

  • ✅ Awaitility wraps only filesystem assertionsMockEndpoint.assertIsSatisfied() calls remain unwrapped (they already wait via CountDownLatch)
  • ✅ All atMost timeouts are explicit (10 seconds)
  • untilAsserted used with clear predicates
  • ✅ No new Thread.sleep introduced
  • ✅ Imports clean — static import for Awaitility.await()

No concerns. Ready for merge (pending human approval).

@davsclaus davsclaus added this to the 4.22.0 milestone Jul 11, 2026
@davsclaus davsclaus merged commit d929942 into apache:main Jul 11, 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