Skip to content

test: spin until the thread reaches barrier.await#199

Merged
paodb merged 1 commit into
masterfrom
fix-197
May 21, 2026
Merged

test: spin until the thread reaches barrier.await#199
paodb merged 1 commit into
masterfrom
fix-197

Conversation

@javier-godoy
Copy link
Copy Markdown
Member

@javier-godoy javier-godoy commented May 21, 2026

Close #197

Summary by CodeRabbit

  • Tests
    • Enhanced synchronization logic in concurrent export tests to ensure more reliable test execution and improved barrier timing validation.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 85389d4c-96d1-4d5a-8f0f-810e1dc385d9

📥 Commits

Reviewing files that changed from the base of the PR and between 6db08bb and 4c1a94e.

📒 Files selected for processing (1)
  • src/test/java/com/flowingcode/vaadin/addons/gridexporter/test/ConcurrentExportTests.java

Walkthrough

Updated MockDownload.await() to include a spin-wait loop that blocks until the download thread reaches Thread.State.WAITING, ensuring the barrier synchronization point is reached before the main test thread proceeds. This eliminates a race condition in testInterruptedByTimeout1.

Changes

Concurrent Export Test Synchronization

Layer / File(s) Summary
MockDownload barrier synchronization
src/test/java/com/flowingcode/vaadin/addons/gridexporter/test/ConcurrentExportTests.java
Added a spin-wait loop in MockDownload.await() that polls until the download thread reaches Thread.State.WAITING, closing the race condition window between latch.countDown() and barrier.await() to ensure correct barrier state before test assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • FlowingCode/GridExporterAddon#195: Earlier synchronization fix in ConcurrentExportTests that introduced state-aware spin-wait for download thread detection; this PR extends that pattern to the main thread side.
  • FlowingCode/GridExporterAddon#125: Introduced the concurrent-download test scaffolding with MockDownload and CyclicBarrier synchronization that this PR now hardens against timing races.

Suggested reviewers

  • mlopezFC
  • paodb
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: spin until the thread reaches barrier.await' directly and specifically describes the main change: adding a spin-wait mechanism to wait for the thread to reach barrier.await().
Linked Issues check ✅ Passed The PR implements the proposed fix from issue #197: adding a spin-wait loop that waits until barrier.getNumberWaiting() >= 1 before asserting, eliminating the race condition between latch.countDown() and barrier.await().
Out of Scope Changes check ✅ Passed All changes are focused on fixing the flaky test race condition described in issue #197. No unrelated modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-197

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

@javier-godoy javier-godoy requested review from paodb and scardanzan May 21, 2026 11:48
@javier-godoy javier-godoy marked this pull request as ready for review May 21, 2026 11:48
@paodb paodb merged commit 34f85d0 into master May 21, 2026
4 checks passed
@paodb paodb deleted the fix-197 branch May 21, 2026 11:59
@github-project-automation github-project-automation Bot moved this from To Do to Pending release in Flowing Code Addons May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pending release

Development

Successfully merging this pull request may close these issues.

Flaky test: testInterruptedByTimeout1 has a race between latch.countDown() and barrier.await()

2 participants