Skip to content

test: retain mock world for command locations - #20

Merged
ryanbarlow97 merged 1 commit into
mainfrom
fix/command-test-world-reference
Oct 12, 2026
Merged

ryanbarlow97 merged 1 commit into
mainfrom
fix/command-test-world-reference

Conversation

@ryanbarlow97

Copy link
Copy Markdown
Contributor

Fixes an intermittent World unloaded error in CommandAndResourceTest that failed the first v3.2.0 release attempt (the rerun passed).

Paper's Location holds its world in a WeakReference and getWorld() throws once it clears. The test kept its mock World only in a @BeforeEach local variable, so the garbage collector could collect it before createresource called Location.getChunk(). The mock is now retained in a field for the test instance's lifetime. Production code is unchanged: a live server holds real worlds strongly.

Validation: tfmc-mvn -o -B -Dtest=CommandAndResourceTest test — 5 tests pass. After this merges, Dowsing will be released as v3.2.1 and the unpublished v3.2.0 draft/tag removed.

@github-actions github-actions Bot added the size:XS 0-9 effective changed lines (tests excluded in mixed PRs). label Oct 12, 2026
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: de0defed-a115-473a-80d9-c229fa3ef83f

📥 Commits

Reviewing files that changed from the base of the PR and between 5ce84d0 and 5f3845e.


📒 Files selected for processing (1)
  • src/test/java/net/tfminecraft/dowsing/managers/CommandAndResourceTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Summary

Summary by CodeRabbit

  • Tests
    • Updated test setup to retain a reference to the mocked world; existing world and player behaviour is unchanged.

Walkthrough

The test class now stores its mocked World in a field. The setup continues to create and stub the mocked world and chunk.

Changes

Test fixture

Layer / File(s) Summary
Store the mocked world in the test fixture
src/test/java/net/tfminecraft/dowsing/managers/CommandAndResourceTest.java
The setup assigns the mocked World to a test-class field instead of a local variable. Existing world and chunk stubbing remains unchanged.

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Other


Merge Risk: ⚪ Minimal · up to 5f384

This change only makes a unit test more reliable and leaves production behavior unchanged. No merge-blocking risk remains.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@ryanbarlow97
ryanbarlow97 merged commit 367b897 into main Oct 12, 2026
3 checks passed
@ryanbarlow97
ryanbarlow97 deleted the fix/command-test-world-reference branch October 12, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant