fix(neo4j): assert background thread completion in OptimisticLockingSpec - #16072
Open
borinquenkid wants to merge 1 commit into
Open
fix(neo4j): assert background thread completion in OptimisticLockingSpec#16072borinquenkid wants to merge 1 commit into
borinquenkid wants to merge 1 commit into
Conversation
Follow-up to #16070. Copilot's review flagged that the second test's Thread.start { ... }.join(2000) can return on timeout without the background thread having actually finished, so the "same headroom rationale" comment added in #16070 was inaccurate there: the sleep could still be masking a race with thread completion, unlike the first test where the unbounded join() guarantees it. Capture the thread and assert !isAlive() after the bounded join so a slow runner fails loudly instead of silently racing the assertions that follow. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens the OptimisticLockingSpec Neo4j test to avoid silently continuing after a timed Thread.join(timeout) that may return before the background write completes, making slow CI runners fail deterministically instead of racing subsequent assertions.
Changes:
- Capture the background update thread in
Test optimistic locking disabled with 'version false'. - Replace
Thread.start { ... }.join(2000)with a stored thread,join(5000), and an explicit!isAlive()completion assertion. - Stop swallowing potential
InterruptedExceptionfrom the join path (now an interrupt will fail the test rather than masking it).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/gorm-registry-core-impl #16072 +/- ##
======================================================================
+ Coverage 52.1558% 52.1662% +0.0104%
- Complexity 18408 18412 +4
======================================================================
Files 2054 2054
Lines 96622 96622
Branches 16846 16846
======================================================================
+ Hits 50394 50404 +10
+ Misses 38835 38825 -10
Partials 7393 7393 🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: cd0502f Learn more about TestLens at testlens.app. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Thread.start { ... }.join(2000)can return on timeout without the background thread having actually finished, so the "same headroom rationale" comment added in test(neo4j): give OptimisticLockingSpec's cross-thread heisenbug more headroom #16070 was inaccurate there.!isAlive()after the boundedjoin(5000)so a slow runner fails loudly instead of silently racing the assertions that follow, instead of swallowing a potentialInterruptedExceptionand hoping for the best.Test plan
grails.gorm.tests.OptimisticLockingSpecingrails-data-neo4j(could not execute this module's tests locally — it's pinned tograils-gradle-plugins:6.1.2, which 404s fromrepo.grails.organd isn't in local caches, a pre-existing environment gap unrelated to this change)🤖 Generated with Claude Code