-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[fix] Avoid negative estimated entry count #24055
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] Avoid negative estimated entry count #24055
Conversation
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Outdated
Show resolved
Hide resolved
@gaoran10 Just wondering how it could the result could exceed |
You can try to use this newly added case in the test, if the bytesSize is a Long max value, the result may beyond the Integer max value.
|
managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
Outdated
Show resolved
Hide resolved
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Outdated
Show resolved
Hide resolved
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Show resolved
Hide resolved
Add the same |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #24055 +/- ##
============================================
+ Coverage 73.57% 74.20% +0.62%
+ Complexity 32624 2379 -30245
============================================
Files 1877 1861 -16
Lines 139502 144214 +4712
Branches 15299 16434 +1135
============================================
+ Hits 102638 107008 +4370
+ Misses 28908 28759 -149
- Partials 7956 8447 +491
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
(cherry picked from commit 49f6236)
(cherry picked from commit 49f6236)
(cherry picked from commit 49f6236)
(cherry picked from commit 49f6236)
Motivation
The estimated entry count may be a negative value in some cases, then the read operation will get an empty result.
Modifications
Add a negative check after the long value converts to an int value.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: