Skip to content

fix(mediator): 修复弱服务注册过期清理 - #9

Merged
faimin merged 1 commit into
mainfrom
bugfix/fix_weakstore_clean
Aug 26, 2026
Merged

faimin merged 1 commit into
mainfrom
bugfix/fix_weakstore_clean

Conversation

@faimin

@faimin faimin commented Aug 26, 2026 •

Copy link
Copy Markdown
Owner
  • 按协议和优先级校验注册 token
  • 避免旧实例释放误删新服务或多协议注册

Summary by CodeRabbit

  • Bug Fixes
    • Improved service registration cleanup when weakly referenced services are released.
    • Prevented outdated cleanup events from removing newer service registrations.
    • Preserved valid registrations when the same service is registered across multiple protocols.
    • Improved handling when replacing weak registrations with strong ones.
    • Ensured service instances are correctly retained, removed, or reinitialized during registration changes.

- 按协议和优先级校验注册 token
- 避免旧实例释放误删新服务或多协议注册
@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f17bb64d-02fe-4e85-bc74-80ff54d6cf78

📥 Commits

Reviewing files that changed from the base of the PR and between 5655896 and c908306.

📒 Files selected for processing (3)
  • Example/Tests/Tests/ZDUnregisterServiceTest.m
  • Sources/Classes/Private/ZDMOneForAll+Private.h
  • Sources/Classes/Public/ZDMOneForAll.m

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


📝 Walkthrough

Walkthrough

The mediator now tracks tokens for weak service registrations. Deallocation callbacks remove a registration only when their token matches the current registration. Tests cover replacement, shared instances, multiple protocols, and explicit removal.

Changes

Weak registration cleanup

Layer / File(s) Summary
Track registration lifetimes
Sources/Classes/Private/ZDMOneForAll+Private.h, Sources/Classes/Public/ZDMOneForAll.m
The mediator stores registration tokens. Weak registrations receive new tokens. Strong and class registrations clear previous tokens.
Validate cleanup and removal
Sources/Classes/Public/ZDMOneForAll.m, Example/Tests/Tests/ZDUnregisterServiceTest.m
Weak cleanup passes the captured token to removal logic. Removal ignores stale callbacks and updates instance state. Tests cover replacement, shared instances, multiple protocols, and explicit removal.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to c9083

This change updates weak-service registration cleanup and adds related tests; no actionable merge-blocking risk remains based on the available evidence.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing stale cleanup for weak service registrations in the mediator.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (2 skipped: 2 unsupported.)

✨ 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 bugfix/fix_weakstore_clean

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.

@faimin

faimin commented Aug 26, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@faimin
faimin merged commit 53d93a4 into main Aug 26, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant