-
Notifications
You must be signed in to change notification settings - Fork 128
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: properly remove subscriptions in ReplayOperator #1483
Conversation
implementation/src/main/java/io/smallrye/mutiny/operators/multi/replay/ReplayOperator.java
Show resolved
Hide resolved
implementation/src/test/java/io/smallrye/mutiny/operators/multi/replay/ReplayOperatorTest.java
Show resolved
Hide resolved
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1483 +/- ##
============================================
- Coverage 89.30% 89.28% -0.02%
- Complexity 3362 3365 +3
============================================
Files 459 459
Lines 13399 13405 +6
Branches 1640 1642 +2
============================================
+ Hits 11966 11969 +3
Misses 802 802
- Partials 631 634 +3
|
97cc53c
to
4e3e15d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, it's definitely going to fix a bug.
See my comments for changes.
I'd have preferred to keep private
access rather than protected
, but it definitely became apparent why you had done so given the final test. Can we think of another way to write this test without:
- going from
private
toprotected
, and - not having to directly instantiate the operator in the test case? (our tests usually create
Multi
pipelines from the user facing API rather than instantiating internals)
Thanks!
implementation/src/main/java/io/smallrye/mutiny/operators/multi/replay/ReplayOperator.java
Show resolved
Hide resolved
implementation/src/main/java/io/smallrye/mutiny/operators/multi/replay/ReplayOperator.java
Show resolved
Hide resolved
implementation/src/test/java/io/smallrye/mutiny/groups/MultiReplayTest.java
Outdated
Show resolved
Hide resolved
implementation/src/test/java/io/smallrye/mutiny/operators/multi/replay/ReplayOperatorTest.java
Show resolved
Hide resolved
Also: you have a merge commit from |
Thanks for the review! I will incorporate the requested changes. Regarding this:
Apart from making the list protected, I can only think of the following alternatives, which one do you prefer?
I don't see another way of ensuring that the subscriptions are properly removed after completion without access to the list. But even then, I wouldn't be able to do this without working with the If none of these options are viable, we'd have to scrap the test. But then you won't have any safety net in case of a regression. |
I agree the |
Fixes a memory leak caused by old subscriptions not being removed properly. In addition, this fixes the edge case where no completion event would be sent for replay subscriptions if the number of requested items was exactly equal to the number of available items. Fixes smallrye#1482
Alright then, thanks 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for spotting and resolving this issue!
Fixes a memory leak caused by old subscriptions not being removed properly. In addition, this fixes the edge case where no completion event would be sent for replay subscriptions if the number of requested items was exactly equal to the number of available items.
Fixes #1482