-
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
Operation take leaks errors #212
Conversation
RxJava-pull-requests #55 FAILURE |
@Test
public void testTakeZeroDoesntLeakError() {
Observable<String> source = Observable.<String> error(new Exception("test failed"));
Observable.create(take(source, 0)).lastOrDefault("ok");
} In that test When 0 is used it's basically saying "don't execute this sequence". Now ... whether that means onError should be ignored is an interesting question. So it could be argued that for this use case it's doing exactly what it should - it doesn't emit any So, should "take 0" be special cased to always just fire I'm interested in what Rx.Net and RxJs do in this case. |
On the other unit test: @Test
public void testTakeDoesntLeakErrors() {
Observable<String> source = Observable.concat(Observable.from("one"), Observable.<String> error(new Exception("test failed")));
Observable.create(take(source, 1)).last();
} This is an interesting one because
Thus, it seems the logic of I'll explore that change. Good finds @johngmyers |
My quick attempt fixed this test case but broke others. The challenge is that the The predicate actually uses the This works for that case, but not the count case. The predicate can't be applied in the Perhaps some special case logic needs to exist for the count use case? I need to punt on this for now as I don't have time to work on it so if you can work on the fix ... or someone else such as @mairbek who worked on this code once already that would be great. |
I believe the That means the implementations of I believe that
|
RxJava-pull-requests #57 SUCCESS |
What I meant about However, as you said the output result should be the same, but on a synchronous origin observable it may end up firehosing all of the onNext values even if an unsubscribe happened early in the sequence and all after the unsubscribe will still be sent but end up ignored which is different behavior than an async sequence. Taking a look at your code now ... |
There's a lot of code there and my brain is done for the night so I'll have to catch up on this later. By the way, I agree with your points in your last comment. |
You can't unsubscribe from a synchronous Observable because you don't have a Subscription until after all the synchronous notifications are done. An unwrapped AtomicObservableSubscription is not a subscription to the Observable. You agree that Is the semantic of * except |
Github's diff doesn't show this well, but I renamed OperatorTake to OperatorTakeWhile (hopefully preserving commit history), changed the class javadoc, and then deleted the take() code from it. |
Yes I know. That was my point.
I think so ... though if the subscribe emits an error (such as on Observable.throw) then take(0) will result in
Rx Design Guidelines 6.5 dictates that The try/catch around an onNext is ensuring that this contract is met even if the implementation of an onNext by a provided Observer does not do proper error handling (most user provided Observers). Guideline 6.6 discusses onError abort semantics so the AtomicObserver also makes sure unsubscribe happens when the terminal state occurs (onError/onCompleted) even if the Observer doesn't handle it correctly in their error handling (which most don't have). It counts on |
RxJava-pull-requests #61 SUCCESS |
Guideline 6.4 explicitly states:
This seems to expressly contraindicate the AtomicObserver.onNext() protection code. |
Manual Merge of Pull Request #212
I merged these changes via #215 Thank you for finding, demonstrating via unit test and fixing these issues @johngmyers |
I have created a separate issue to discuss the other possible issue you brought up: #216 |
…-merge Manual Merge of Pull Request ReactiveX#212
…eption is… (ReactiveX#213) * ReactiveX#212 reactor.core.Exceptions$BubblingException thrown if exception is thrown in subscribe * ReactiveX#35 Fix Codacity issues
…hat a CircuitBreakerException is thrown when you subscribe to Flux.error.
…hat an error is propagated when you subscribe to Flux.error, but the error is not thrown onSubscribe.
…ctiveX#214) Check that we are getting the resilience exception even when the source will throw an exception (not on subscribe)
The take() operator improperly propagates an error from its source after the count has been exhausted.
Test cases exhibiting the bug attached.