Skip to content

chore: fix limit and limitWeighted Scaladoc - #3591

Merged
He-Pin merged 1 commit into
apache:mainfrom
pjfanning:scaladoc-limitweighted
Oct 9, 2026
Merged

He-Pin merged 1 commit into
apache:mainfrom
pjfanning:scaladoc-limitweighted

Conversation

@pjfanning

Copy link
Copy Markdown
Member

Motivation

The Scaladoc of limit and limitWeighted does not match the code:

  • the javadsl Flow, Source, SubFlow and SubSource versions were copied
    from take: they say the stream completes when "the defined number of
    elements has been taken" and completes without producing elements
    when n is zero or negative, but these operators fail the stream with
    StreamLimitReachedException once the limit is exceeded
  • the scaladsl limitWeighted "Completes when" line talks about the
    number of emitted elements rather than the accumulated cost
  • all of them name the exception StreamLimitException, which does not
    exist; LimitWeighted fails with StreamLimitReachedException

Modification

Describe the actual behaviour in the Emits/Completes/Errors/Cancels
lines of limit and limitWeighted in scaladsl Flow and javadsl Flow,
Source, SubFlow and SubSource, drop the copied zero-or-negative
sentence, add the missing Errors lines and name
StreamLimitReachedException.

Result

The Scaladoc matches the LimitWeighted stage (limit is limitWeighted
with a cost of 1 per element).

Tests

  • Not run - Scaladoc only

References

Refs #3590

Motivation:
The Scaladoc of limit and limitWeighted does not match the code:
- the javadsl Flow, Source, SubFlow and SubSource versions were copied
  from take: they say the stream completes when "the defined number of
  elements has been taken" and completes without producing elements
  when n is zero or negative, but these operators fail the stream with
  StreamLimitReachedException once the limit is exceeded
- the scaladsl limitWeighted "Completes when" line talks about the
  number of emitted elements rather than the accumulated cost
- all of them name the exception StreamLimitException, which does not
  exist; LimitWeighted fails with StreamLimitReachedException

Modification:
Describe the actual behaviour in the Emits/Completes/Errors/Cancels
lines of limit and limitWeighted in scaladsl Flow and javadsl Flow,
Source, SubFlow and SubSource, drop the copied zero-or-negative
sentence, add the missing Errors lines and name
StreamLimitReachedException.

Result:
The Scaladoc matches the LimitWeighted stage (limit is limitWeighted
with a cost of 1 per element).

Tests:
- Not run - Scaladoc only

References:
Refs apache#3590
@pjfanning pjfanning added this to the 2.0.0-M5 milestone Oct 8, 2026

@He-Pin He-Pin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The StreamLimitReachedException fix and the removal of the zero/negative sentence are both correct against Ops.scala and StreamLimitReachedException.scala, and DSL parity looks complete. One thing still open before I merge: the published operator docs still carry the exact defect you are fixing here.

@He-Pin
He-Pin force-pushed the scaladoc-limitweighted branch from e7fcca2 to 816baa9 Compare October 9, 2026 05:38
@He-Pin
He-Pin merged commit 6e32da2 into apache:main Oct 9, 2026
20 checks passed
@pjfanning
pjfanning deleted the scaladoc-limitweighted branch October 9, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants