Repository navigation
4.x: Fix Streamable.intervalRange emitting nothing when start + count overflows - #8398
Merged
Merged
Conversation
… overflows intervalRange accepts start + count == Long.MAX_VALUE + 1, for example start = 1 with count = Long.MAX_VALUE, which the Javadoc suggests for an unlimited range. The streamer stored end = start + count, which wraps to Long.MIN_VALUE, so counterLocal >= end held right away and the sequence completed empty. Compare against the end through a subtraction so the wrapped end still works, as Flowable.intervalRange does with c == end.
🐷 TruffleHog + Entropy Beauty ScanAverage entropy of changed code: 4.576 bits/char Changed files entropy: ✅ No secrets or suspicious high-entropy strings found. Mid-4 beauty heuristic in action — powered by our entropy chats! 😊 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.x #8398 +/- ##
============================================
+ Coverage 98.60% 98.61% +0.01%
Complexity 7182 7182
============================================
Files 826 826
Lines 51038 51038
Branches 6944 6944
============================================
+ Hits 50326 50333 +7
+ Misses 481 477 -4
+ Partials 231 228 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
akarnokd
approved these changes
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Streamable.intervalRange(1, Long.MAX_VALUE, ...)completes without emitting anything. The Javadoc suggestsLong.MAX_VALUEas the count for an unlimited range, and the factory overflow check accepts this call (underNoOverflowLongcovers the boundary), but the sequence is empty. The same happens for any range whose last value is exactlyLong.MAX_VALUE, for exampleintervalRange(Long.MAX_VALUE - 2, 3, ...).StreamableIntervalRange.stream()creates the streamer withend = start + itemCount, which wraps toLong.MIN_VALUEin these cases.next()then seescounterLocal >= endon the first call and returns false, andrun()disposes the timer on its first tick becausec + 1 >= end.The fix compares through a subtraction (
counterLocal - end >= 0andc + 1 - end >= 0), which stays correct whenendwrapped since the distance fromstarttoendnever exceedsLong.MAX_VALUE.count == 0still ends right away. This is the same boundary #8337 fixed forrange/rangeLong;FlowableIntervalRangealready handles it withc == end.I added
maxValueEndandunlimitedFromOnetoStreamableIntervalRangeTest. Before the fix both fail withgot: 0 []and one completion. After the fix the wholeStreamableIntervalRangeTestpasses (23 tests, 1 skipped as before).AI disclosure: the defect, the fix and the tests were found and written with AI. Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.5.