-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
2.x: Fix buffer(open, close) not disposing indicators properly #5811
Conversation
@akarnokd let me know if I understand the spirit of this PR on
Is that correct/exhaustive? |
Yes.
Yes.
No. If the |
Codecov Report
@@ Coverage Diff @@
## 2.x #5811 +/- ##
============================================
+ Coverage 96.28% 96.39% +0.11%
+ Complexity 5817 5814 -3
============================================
Files 634 634
Lines 41647 41761 +114
Branches 5776 5796 +20
============================================
+ Hits 40098 40255 +157
+ Misses 611 583 -28
+ Partials 938 923 -15
Continue to review full report at Codecov.
|
for (C b : bufs.values()) { | ||
queue.offer(b); | ||
} | ||
bufs = null; |
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.
shouldn't this be buffers = null
?
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.
Yes, fixed. Also combined the error methods and changed to LinkedHashMap so that the final open buffers in onComplete
remain in their order they were opened.
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.
got it, looking better with the buffers null-out and the mutualized boundaryError
👍
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.
gave quick scan only
} | ||
|
||
emitted = e; | ||
missed = addAndGet(-missed); |
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.
requested
not getting reduced by emitted
?
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.
No longer necessary in these type of drain loops. requested
can only grow and the emitted
will follow it separately. This saves an atomic decrement here.
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.
ok, beaut
resources.add(bcs); | ||
void boundaryError(Disposable subscriber, Throwable ex) { | ||
SubscriptionHelper.cancel(upstream); | ||
subscribers.delete(subscriber); |
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.
Can we just dispose()
all subscribers here and remove dispose()
call below?
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.
Same in Observable version
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.
It avoids disposing the caller which is known to have reached its terminal state.
a.onError(ex); | ||
return; | ||
} else | ||
if (q.isEmpty()) { |
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.
nit: formatting, this line typically goes on the same line with else
} catch (Throwable ex) { | ||
Exceptions.throwIfFatal(ex); | ||
SubscriptionHelper.cancel(upstream); | ||
if (errors.addThrowable(ex)) { |
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.
if/else block seems to be exact same as onError()
, let's just call it here?
void boundaryError(Disposable subscriber, Throwable ex) { | ||
SubscriptionHelper.cancel(upstream); | ||
subscribers.delete(subscriber); | ||
if (errors.addThrowable(ex)) { |
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.
if/else block seems to be exact same as onError()
, let's just call it here?
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.
Same in Observable version
@Test | ||
@SuppressWarnings("unchecked") | ||
public void boundaryOpenCloseDisposedOnComplete() { | ||
PublishProcessor<Integer> pp0 = PublishProcessor.create(); |
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.
nit: upstream
public void boundaryOpenCloseDisposedOnComplete() { | ||
PublishProcessor<Integer> pp0 = PublishProcessor.create(); | ||
|
||
PublishProcessor<Integer> pp1 = PublishProcessor.create(); |
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.
nit: openingIndicator
|
||
PublishProcessor<Integer> pp1 = PublishProcessor.create(); | ||
|
||
PublishProcessor<Integer> pp2 = PublishProcessor.create(); |
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.
nit: closingIndicator
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.
and same in some tests below
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.
lgtm
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.
👍
The PR fixes the resource management in the
buffer
operator that uses other reactive sources to indicate when a buffer starts and ends. BothFlowable
andObservable
implementations had to be fixed.Fixes: #5809