use of io.reactivex.rxjava3.internal.util.AtomicThrowable in project RxJava by ReactiveX.
the class HalfSerializerObserverTest method reentrantErrorOnError.
@Test
@SuppressUndeliverable
@SuppressWarnings({ "rawtypes", "unchecked" })
public void reentrantErrorOnError() {
final AtomicInteger wip = new AtomicInteger();
final AtomicThrowable error = new AtomicThrowable();
final Observer[] a = { null };
final TestObserver to = new TestObserver();
Observer observer = new Observer() {
@Override
public void onSubscribe(Disposable d) {
to.onSubscribe(d);
}
@Override
public void onNext(Object t) {
to.onNext(t);
}
@Override
public void onError(Throwable t) {
to.onError(t);
HalfSerializer.onError(a[0], new IOException(), wip, error);
}
@Override
public void onComplete() {
to.onComplete();
}
};
a[0] = observer;
observer.onSubscribe(Disposable.empty());
HalfSerializer.onError(observer, new TestException(), wip, error);
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.internal.util.AtomicThrowable in project RxJava by ReactiveX.
the class HalfSerializerSubscriberTest method reentrantOnNextOnComplete.
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void reentrantOnNextOnComplete() {
final AtomicInteger wip = new AtomicInteger();
final AtomicThrowable error = new AtomicThrowable();
final Subscriber[] a = { null };
final TestSubscriber ts = new TestSubscriber();
FlowableSubscriber s = new FlowableSubscriber() {
@Override
public void onSubscribe(Subscription s) {
ts.onSubscribe(s);
}
@Override
public void onNext(Object t) {
if (t.equals(1)) {
HalfSerializer.onComplete(a[0], wip, error);
}
ts.onNext(t);
}
@Override
public void onError(Throwable t) {
ts.onError(t);
}
@Override
public void onComplete() {
ts.onComplete();
}
};
a[0] = s;
s.onSubscribe(new BooleanSubscription());
HalfSerializer.onNext(s, 1, wip, error);
ts.assertResult(1);
}
use of io.reactivex.rxjava3.internal.util.AtomicThrowable in project RxJava by ReactiveX.
the class HalfSerializerSubscriberTest method reentrantErrorOnError.
@Test
@SuppressUndeliverable
@SuppressWarnings({ "rawtypes", "unchecked" })
public void reentrantErrorOnError() {
final AtomicInteger wip = new AtomicInteger();
final AtomicThrowable error = new AtomicThrowable();
final Subscriber[] a = { null };
final TestSubscriber ts = new TestSubscriber();
FlowableSubscriber s = new FlowableSubscriber() {
@Override
public void onSubscribe(Subscription s) {
ts.onSubscribe(s);
}
@Override
public void onNext(Object t) {
ts.onNext(t);
}
@Override
public void onError(Throwable t) {
ts.onError(t);
HalfSerializer.onError(a[0], new IOException(), wip, error);
}
@Override
public void onComplete() {
ts.onComplete();
}
};
a[0] = s;
s.onSubscribe(new BooleanSubscription());
HalfSerializer.onError(s, new TestException(), wip, error);
ts.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.internal.util.AtomicThrowable in project RxJava by ReactiveX.
the class HalfSerializerSubscriberTest method onErrorOnCompleteRace.
@Test
@SuppressUndeliverable
public void onErrorOnCompleteRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final AtomicInteger wip = new AtomicInteger();
final AtomicThrowable error = new AtomicThrowable();
final TestSubscriberEx<Integer> ts = new TestSubscriberEx<>();
ts.onSubscribe(new BooleanSubscription());
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
HalfSerializer.onError(ts, ex, wip, error);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
HalfSerializer.onComplete(ts, wip, error);
}
};
TestHelper.race(r1, r2);
if (ts.completions() != 0) {
ts.assertResult();
} else {
ts.assertFailure(TestException.class);
}
}
}
use of io.reactivex.rxjava3.internal.util.AtomicThrowable in project RxJava by ReactiveX.
the class AtomicThrowableTest method tryTerminateConsumerEmitterError.
@Test
public void tryTerminateConsumerEmitterError() {
TestObserver<Object> to = new TestObserver<>();
to.onSubscribe(Disposable.empty());
AtomicThrowable ex = new AtomicThrowable();
ex.set(new TestException());
ex.tryTerminateConsumer(wrapToEmitter(to));
to.assertFailure(TestException.class);
}
Aggregations