1.x: fix and deprecate evicting groupBy and add new overload by davidmoten · Pull Request #5917 · ReactiveX/RxJava · GitHub
Skip to content

1.x: fix and deprecate evicting groupBy and add new overload#5917

Merged
akarnokd merged 2 commits into
ReactiveX:1.xfrom
davidmoten:groupby-eviction2
Mar 19, 2018
Merged

1.x: fix and deprecate evicting groupBy and add new overload#5917
akarnokd merged 2 commits into
ReactiveX:1.xfrom
davidmoten:groupby-eviction2

Conversation

@davidmoten

Copy link
Copy Markdown
Collaborator

See #5868

There is a problem with the existing 1.x Observable.groupBy overload with an evicting map factory where depending on the eviction behaviour of the supplied map factory, groups may not be completed and may leak memory. The problem extends to the method signature in that the eviction action should report the evicted GroupedObservable not the corresponding key.

This PR

  • fixes the existing method at the expense of doubling up the internal map groups ( into groupsCopy) so that we can always successfully lookup the evicted group from the groupsCopy map. Evictions from groups are mirrored in groupsCopy after the lookup.
  • deprecates the problematic overload indicating that it uses more memory than the preferred new overload
  • adds a new method groupBy that has the corrected signature and offers bufferSize and delayError parameters for a bit more flexibility and to differentiate the erased signature from the deprecated method
  • adds tests that were ported from the 2.x tests

@codecov

codecov Bot commented Mar 15, 2018

Copy link
Copy Markdown

@davidmoten

Copy link
Copy Markdown
Collaborator Author

Added a null check because a race with cancel could clear groupsCopy

@akarnokd akarnokd merged commit e467798 into ReactiveX:1.x Mar 19, 2018
@davidmoten

Copy link
Copy Markdown
Collaborator Author

Can we get another 1.x release with this change soonish?

@akarnokd

Copy link
Copy Markdown
Member

Done.

@davidmoten

Copy link
Copy Markdown
Collaborator Author

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