-
Notifications
You must be signed in to change notification settings - Fork 218
enh-5499:removed unwrap and added an error #5550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughReplaces an unconditional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
|
🔊@albertbolt1 🚀Thanks for your contribution🎉! 💡CodeRabbit(AI) will review your code first🔥! Note 🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
rocketmq-client/src/producer/default_mq_producer.rs (1)
948-948: Consider replacing remaining unwraps for consistency.Several other methods still use
unwrap()ondefault_mqproducer_impl:
- Line 948:
send_batch()- Line 1034:
send_batch_with_callback_timeout()- Line 1053:
send_batch_to_queue_with_callback()- Line 1072:
send_batch_to_queue_with_callback_timeout()For consistency and robustness, consider replacing these with the same
ok_or()pattern used in therequest()method to prevent potential panics.♻️ Example fix for line 948
- let result = self.default_mqproducer_impl.as_mut().unwrap().send(&mut batch).await?; + let result = self + .default_mqproducer_impl + .as_mut() + .ok_or(RocketMQError::not_initialized("DefaultMQProducerImpl not initialized"))? + .send(&mut batch) + .await?;Apply similar changes to the other locations.
Also applies to: 1034-1034, 1053-1053, 1072-1072
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
rocketmq-client/src/producer/default_mq_producer.rs
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-05-10T06:20:00.401Z
Learnt from: 578223592
Repo: mxsm/rocketmq-rust PR: 3240
File: rocketmq-namesrv/src/kvconfig/kvconfig_mananger.rs:69-71
Timestamp: 2025-05-10T06:20:00.401Z
Learning: In RocketMQ Rust, while dashmap is concurrent-safe, returning a direct reference to a DashMap can break encapsulation by allowing external code to modify the map without triggering persistence methods like `persist()`. Consider returning a read-only view, iterator methods, or a snapshot instead.
Applied to files:
rocketmq-client/src/producer/default_mq_producer.rs
🧬 Code graph analysis (1)
rocketmq-client/src/producer/default_mq_producer.rs (1)
rocketmq-error/src/unified.rs (1)
not_initialized(534-536)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Code Coverage
- GitHub Check: Build & Test (windows-latest)
- GitHub Check: Build & Test (ubuntu-latest)
- GitHub Check: Build & Test (macos-latest)
- GitHub Check: auto-approve
🔇 Additional comments (2)
rocketmq-client/src/producer/default_mq_producer.rs (2)
1086-1091: LGTM! Proper error handling replaces unwrap.The change correctly replaces a potential panic with explicit error handling using
ok_or(), returning aRocketMQError::NotInitializedwhen the producer implementation is not initialized. This aligns with the PR objective and matches the pattern used consistently throughout the file.
1204-1329: Excellent test coverage for error handling.The added tests thoroughly verify that the methods return a
NotInitializederror whendefault_mqproducer_implisNone, ensuring the error handling behaves as expected.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5550 +/- ##
=======================================
Coverage 38.43% 38.43%
=======================================
Files 815 815
Lines 110551 110551
=======================================
+ Hits 42490 42494 +4
+ Misses 68061 68057 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rocketmq-rust-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - All CI checks passed ✅
Which Issue(s) This PR Fixes(Closes)
Fixes #5499
Brief Description
removed unwrap and added an error
How Did You Test This Change?
ran the test cases to check if anything is breaking
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.