-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][broker] Fix NPE and annotate nullable return values for ManagedCursorContainer #24706
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
[fix][broker] Fix NPE and annotate nullable return values for ManagedCursorContainer #24706
Conversation
poorbarcode
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.
Thanks for fixing it
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #24706 +/- ##
============================================
+ Coverage 74.18% 74.20% +0.01%
+ Complexity 33472 33463 -9
============================================
Files 1895 1895
Lines 147968 147976 +8
Branches 17134 17137 +3
============================================
+ Hits 109768 109803 +35
+ Misses 29448 29411 -37
- Partials 8752 8762 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…CursorContainer (apache#24706) (cherry picked from commit 7988f4f)
…CursorContainer (apache#24706) (cherry picked from commit 7988f4f)
Motivation
I observed the following NPE when I ran some tests.
It's because
getCursorWithOldestPositioncould return null butcheckMessageExpiryWithSharedPositiondoes not apply null validation.Modifications
Add
@Nullableannotations to allManagedCursorContainer's methods of that could return null. Then check all non-test code and add null validation if missed:checkMessageExpiryWithSharedPositionadded in [improve][broker]Find the target position at most once, during expiring messages for a topic, even though there are many subscriptions #24622getSlowedConsumersince a very early commit, but not sure why the NPE was never reportedP.S. Using
Optionalmight be a better alternative to force users to check null because many developers still ignore warnings. To avoid unnecessary heap allocation and API changes, I didn't change the method signature.Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: