-
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
Exception not properly propagated #417
Comments
Here the error occurs even without System.out.println(Observable.from(1, 2, 3).take(1).map(f).toBlockingObservable().single()); This snippet also makes the app never terminate. This prevents me from implementing the head operation in the Scala adaptor, and the original one with |
For @Override
public void onError(Throwable e) {
if (counter.getAndSet(num) < num) {
observer.onError(e);
}
}
@Override
public void onNext(T args) {
final int count = counter.incrementAndGet();
if (count <= num) {
observer.onNext(args);
if (count == num) {
observer.onCompleted();
}
}
if (count >= num) {
// this will work if the sequence is asynchronous, it will have no effect on a synchronous observable
subscription.unsubscribe();
}
} For |
This issue is because switch (notification.getKind()) {
case OnNext:
underlying.onNext(notification.getValue());
break;
case OnError:
underlying.onError(notification.getThrowable());
break;
case OnCompleted:
underlying.onCompleted();
break;
default:
throw new IllegalStateException("Unknown kind of notification " + notification);
} |
@benjchristensen I encountered one problem which I had never realized before when I tried to solve this issue. From the Observable's perspective, it can guarantee that it calls For example, an Observable calls I really think such case is weird for the Observer. Could you point out where I misunderstood? |
I read the article about concurrency in Rx: http://www.introtorx.com/Content/v1.0.10621.0/15_SchedulingAndThreading.html.
|
@benjchristensen, one more question. If an Observer throws an exception in For example, in @samuelgruetter 's example, public static void main(String[] args) {
System.out.println("started");
System.out.println(Observable.from(1).observeOn(Schedulers.threadPoolForComputation())
.map(f).toBlockingObservable().single());
System.out.println("done");
}
I'm trapped in here. Due to |
You should read the "Rx Design Guidelines" => http://blogs.msdn.com/b/rxteam/archive/2010/10/28/rx-design-guidelines.aspx
There is nothing requiring it be the same thread necessarily, but it is required that it being sequential and synchronized so the Observer doesn't need to worry about memory visibility, interleaving calls etc. See section 6.7 and 6.8 of the design guidelines.
It's the same, a Scheduler is for moving location and time but does not change the contract. A single Observable must still be serialized. Anything in RxJava doing differently is a bug and needs to be fixed. We iterated several times on |
If they are out-of-order then we still don't have |
Thanks for your help. "Rx Design Guidelines" is really helpful. |
… to close a bulkhead fully. (ReactiveX#433)
Given
when I run this:
I get (as expected) this output:
However, when I observe it on a different thread:
then the output is this:
and the application does not terminate.
But I would expect that no matter on what thread I observe, errors are always propagated.
The text was updated successfully, but these errors were encountered: