Skip to content

Commit

Permalink
2.x: Report errors from onError to Plugin when done (#4590)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanniktech authored and akarnokd committed Sep 23, 2016
1 parent c5e38ce commit 7791076
Show file tree
Hide file tree
Showing 23 changed files with 94 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package io.reactivex.internal.operators.flowable;

import io.reactivex.plugins.RxJavaPlugins;
import org.reactivestreams.*;

import io.reactivex.exceptions.Exceptions;
Expand Down Expand Up @@ -76,10 +77,13 @@ public void onNext(T t) {

@Override
public void onError(Throwable t) {
if (!done) {
done = true;
actual.onError(t);
if (done) {
RxJavaPlugins.onError(t);
return;
}

done = true;
actual.onError(t);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,14 @@ public void onNext(T t) {

@Override
public void onError(Throwable t) {
if (!done) {
done = true;
s = SubscriptionHelper.CANCELLED;
actual.onError(t);
if (done) {
RxJavaPlugins.onError(t);
return;
}

done = true;
s = SubscriptionHelper.CANCELLED;
actual.onError(t);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package io.reactivex.internal.operators.flowable;

import io.reactivex.plugins.RxJavaPlugins;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.*;

Expand Down Expand Up @@ -309,6 +310,7 @@ void tryEmit(U value, InnerSubscriber<T, U> inner) {
public void onError(Throwable t) {
// safeguard against misbehaving sources
if (done) {
RxJavaPlugins.onError(t);
return;
}
getErrorQueue().offer(t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package io.reactivex.internal.operators.flowable;

import io.reactivex.plugins.RxJavaPlugins;
import java.util.concurrent.atomic.AtomicLong;

import org.reactivestreams.*;
Expand Down Expand Up @@ -97,6 +98,7 @@ public void onNext(T t) {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package io.reactivex.internal.operators.flowable;

import io.reactivex.plugins.RxJavaPlugins;
import org.reactivestreams.*;

import io.reactivex.internal.subscriptions.*;
Expand Down Expand Up @@ -73,6 +74,7 @@ public void onNext(T t) {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void onNext(T t) {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void onNext(T t) {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package io.reactivex.internal.operators.flowable;

import io.reactivex.plugins.RxJavaPlugins;
import org.reactivestreams.*;

import io.reactivex.exceptions.Exceptions;
Expand Down Expand Up @@ -80,6 +81,7 @@ public void onNext(T t) {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.reactivex.exceptions.Exceptions;
import io.reactivex.functions.Predicate;
import io.reactivex.internal.disposables.DisposableHelper;
import io.reactivex.plugins.RxJavaPlugins;

public final class ObservableAny<T> extends AbstractObservableWithUpstream<T, Boolean> {
final Predicate<? super T> predicate;
Expand Down Expand Up @@ -75,10 +76,13 @@ public void onNext(T t) {

@Override
public void onError(Throwable t) {
if (!done) {
done = true;
actual.onError(t);
if (done) {
RxJavaPlugins.onError(t);
return;
}

done = true;
actual.onError(t);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@ public void onNext(T t) {

@Override
public void onError(Throwable t) {
if (!done) {
done = true;
actual.onError(t);
if (done) {
RxJavaPlugins.onError(t);
return;
}

done = true;
actual.onError(t);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.reactivex.*;
import io.reactivex.disposables.Disposable;
import io.reactivex.internal.disposables.DisposableHelper;
import io.reactivex.plugins.RxJavaPlugins;

public final class ObservableElementAt<T> extends AbstractObservableWithUpstream<T, T> {
final long index;
Expand Down Expand Up @@ -86,6 +87,7 @@ public void onNext(T t) {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public void onNext(T t) {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.reactivex.*;
import io.reactivex.disposables.Disposable;
import io.reactivex.internal.disposables.DisposableHelper;
import io.reactivex.plugins.RxJavaPlugins;

public final class ObservableElementAtSingle<T> extends Single<T> {
final ObservableSource<T> source;
Expand Down Expand Up @@ -86,6 +87,7 @@ public void onNext(T t) {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package io.reactivex.internal.operators.observable;

import io.reactivex.plugins.RxJavaPlugins;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.*;
Expand Down Expand Up @@ -277,8 +278,8 @@ void tryEmit(U value, InnerObserver<T, U> inner) {

@Override
public void onError(Throwable t) {
// safeguard against misbehaving sources
if (done) {
RxJavaPlugins.onError(t);
return;
}
getErrorQueue().offer(t);
Expand All @@ -288,7 +289,6 @@ public void onError(Throwable t) {

@Override
public void onComplete() {
// safeguard against misbehaving sources
if (done) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.reactivex.*;
import io.reactivex.disposables.Disposable;
import io.reactivex.internal.disposables.DisposableHelper;
import io.reactivex.plugins.RxJavaPlugins;

public final class ObservableSingle<T> extends AbstractObservableWithUpstream<T, T> {

Expand Down Expand Up @@ -82,6 +83,7 @@ public void onNext(T t) {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.reactivex.*;
import io.reactivex.disposables.Disposable;
import io.reactivex.internal.disposables.DisposableHelper;
import io.reactivex.plugins.RxJavaPlugins;

public final class ObservableSingleMaybe<T> extends Maybe<T> {

Expand Down Expand Up @@ -79,6 +80,7 @@ public void onNext(T t) {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.reactivex.*;
import io.reactivex.disposables.Disposable;
import io.reactivex.internal.disposables.DisposableHelper;
import io.reactivex.plugins.RxJavaPlugins;

public final class ObservableSingleSingle<T> extends Single<T> {

Expand Down Expand Up @@ -85,6 +86,7 @@ public void onNext(T t) {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.reactivex.*;
import io.reactivex.disposables.Disposable;
import io.reactivex.internal.disposables.*;
import io.reactivex.plugins.RxJavaPlugins;

public final class ObservableTake<T> extends AbstractObservableWithUpstream<T, T> {
final long limit;
Expand Down Expand Up @@ -66,11 +67,14 @@ public void onNext(T t) {
}
@Override
public void onError(Throwable t) {
if (!done) {
done = true;
subscription.dispose();
actual.onError(t);
if (done) {
RxJavaPlugins.onError(t);
return;
}

done = true;
subscription.dispose();
actual.onError(t);
}
@Override
public void onComplete() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.reactivex.exceptions.Exceptions;
import io.reactivex.functions.Predicate;
import io.reactivex.internal.disposables.DisposableHelper;
import io.reactivex.plugins.RxJavaPlugins;

public final class ObservableTakeWhile<T> extends AbstractObservableWithUpstream<T, T> {
final Predicate<? super T> predicate;
Expand Down Expand Up @@ -92,6 +93,7 @@ public void onNext(T t) {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/reactivex/observers/SafeObserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ void onNextNoSubscription() {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/reactivex/subjects/UnicastSubject.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package io.reactivex.subjects;

import io.reactivex.plugins.RxJavaPlugins;
import java.util.concurrent.atomic.*;

import io.reactivex.Observer;
Expand Down Expand Up @@ -193,6 +194,7 @@ public void onNext(T t) {
@Override
public void onError(Throwable t) {
if (done || disposed) {
RxJavaPlugins.onError(t);
return;
}
if (t == null) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/reactivex/subscribers/SafeSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ void onNextNoSubscription() {
@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
Expand Down
Loading

0 comments on commit 7791076

Please sign in to comment.