Skip to content

4.x: Fix Streamable range traversal starts and maximum endpoints - #8337

Merged
akarnokd merged 1 commit into
ReactiveX:4.xfrom
PHJ2000:fix-streamable-range-traversal
Oct 23, 2026
Merged

akarnokd merged 1 commit into
ReactiveX:4.xfrom
PHJ2000:fix-streamable-range-traversal

Conversation

@PHJ2000

@PHJ2000 PHJ2000 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Streamable.rangeLong(5, 2) yields [5, 6] normally, but adding filter(_ -> true).collect(Collectors.toList()) yields [1, 2, 3, 4, 5, 6]. The enumerable traversal starts from the default current value instead of the requested start. Zero and negative starts are affected too.

Separately, the same synchronous range implementations emit no values for valid two-element ranges ending at Integer.MAX_VALUE or Long.MAX_VALUE, because their exclusive endpoint wraps and the traversal uses a signed ordering comparison.

Use the same index-based step for next() and nextSync(), and stop when the index equals the exclusive endpoint. This matches the existing wrap-safe approach in FlowableRangeLong. The indexed elementAt/limit path and public range validation remain unchanged.

Ten new test methods cover non-one long starts and both primitive endpoints via ordinary and filtered/enumerable consumption. On the base, eight fail (24 total entries, one inherited disabled test). After the fix, the range suite plus required validators pass: 323 entries, 28 skipped, no failures/errors, using Temurin JDK 26.0.2.1. Full build javadoc also passes: JUnit 14,292 entries (878 skipped), TestNG 5,796 entries (1,795 skipped), zero failures. Checkstyle and Javadoc complete successfully. Test workers were limited to two to share local build resources.

This was found by source inspection and local synthetic reproductions, not a reported production incident.

AI disclosure: OpenAI Codex performed the investigation, implementation, tests, and PR drafting. A separate AI session performs independent review; that is not human review. The reasoning was to check all synchronous range consumption paths and primitive boundaries, then share the index step to remove the divergence without changing public APIs.

Use the same index-based step for asynchronous and enumerable consumption. Comparing the next index to the exclusive endpoint supports ranges ending at the primitive maximum without changing indexed collection.

Generated-by: OpenAI Codex
@akarnokd akarnokd added this to the 4.0 milestone Oct 23, 2026
@github-actions

Copy link
Copy Markdown

🐷 TruffleHog + Entropy Beauty Scan

Average entropy of changed code: 4.644 bits/char
Verdict: ✅ Mid-4 beauty detected (thoughtful human code!)

Changed files entropy:

src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableRange.java: 4.557
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableRangeLong.java: 4.577
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableRangeTest.java: 4.798

✅ No secrets or suspicious high-entropy strings found.

Mid-4 beauty heuristic in action — powered by our entropy chats! 😊

@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.66%. Comparing base (dc37755) to head (9868e26).

Additional details and impacted files
@@             Coverage Diff              @@
##                4.x    #8337      +/-   ##
============================================
+ Coverage     98.62%   98.66%   +0.03%     
- Complexity     7167     7169       +2     
============================================
  Files           826      826              
  Lines         50972    50972              
  Branches       6944     6944              
============================================
+ Hits          50271    50289      +18     
+ Misses          477      463      -14     
+ Partials        224      220       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@akarnokd
akarnokd merged commit 8d02a62 into ReactiveX:4.x Oct 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants