本文整理匯總了Java中org.reactivestreams.Subscriber.onError方法的典型用法代碼示例。如果您正苦於以下問題:Java Subscriber.onError方法的具體用法?Java Subscriber.onError怎麽用?Java Subscriber.onError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.reactivestreams.Subscriber
的用法示例。
在下文中一共展示了Subscriber.onError方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fail
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
protected void fail(Throwable failure) {
synchronized (this) {
state = State.FAILING;
this.failure = failure;
}
Subscriber<? super T> subscriber = subscriber();
if (subscriber != null) {
boolean error = false;
synchronized (this) {
if (state == State.FAILING) {
state = State.TERMINATED;
error = true;
}
}
if (error) {
subscriber.onError(failure);
}
}
}
示例2: fastPath
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
void fastPath() {
T[] arr = array;
int f = arr.length;
Subscriber<? super T> a = actual;
for (int i = index; i != f; i++) {
if (cancelled) {
return;
}
T t = arr[i];
if (t == null) {
a.onError(new NullPointerException("array element is null"));
return;
} else {
a.onNext(t);
}
}
if (cancelled) {
return;
}
a.onComplete();
}
示例3: subscribeActual
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
public void subscribeActual(Subscriber<? super T> s) {
DeferredScalarSubscription<T> deferred = new DeferredScalarSubscription<T>(s);
s.onSubscribe(deferred);
T v;
try {
v = unit != null ? future.get(timeout, unit) : future.get();
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
if (!deferred.isCancelled()) {
s.onError(ex);
}
return;
}
if (v == null) {
s.onError(new NullPointerException("The future returned null"));
} else {
deferred.complete(v);
}
}
示例4: subscribeActual
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
public void subscribeActual(Subscriber<? super T> s) {
DeferredScalarSubscription<T> deferred = new DeferredScalarSubscription<T>(s);
s.onSubscribe(deferred);
T t;
try {
t = ObjectHelper.requireNonNull(callable.call(), "The callable returned a null value");
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
s.onError(ex);
return;
}
deferred.complete(t);
}
示例5: doOnEmpty
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
public static <T> FlowableOperator<T, T> doOnEmpty(Action
action) {
return new FlowableOperator<T, T>() {
@Override
public Subscriber<? super T> apply(Subscriber<? super
T> subscriber) throws Exception {
return new DisposableSubscriber<T>() {
boolean isEmpty = true;
@Override
public void onNext(T value) {
isEmpty = false;
subscriber.onNext(value);
}
@Override
public void onError(Throwable t) {
subscriber.onError(t);
}
@Override
public void onComplete() {
if (isEmpty) {
try {
action.run();
} catch (Exception e) {
onError(e);
return;
}
}
subscriber.onComplete();
}
};
}
};
}
示例6: apply
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
public Subscriber<? super T> apply(final Subscriber<? super T> observer) {
return new Subscriber<T>() {
@Override
public void onSubscribe(Subscription subscription) {
if (subscribedOnce.getAndSet(true)) {
throw new NullPointerException("You cannot directly subscribe to a gRPC service multiple times " +
"concurrently. Use Flowable.share() instead.");
} else {
observer.onSubscribe(subscription);
}
}
@Override
public void onNext(T t) {
observer.onNext(t);
}
@Override
public void onError(Throwable throwable) {
observer.onError(throwable);
}
@Override
public void onComplete() {
observer.onComplete();
}
};
}
示例7: subscribe
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
public void subscribe(final Subscriber<? super T> subscriber) {
try {
subscriber.onSubscribe(new ReactiveSubscription<T>(this, subscriber) {
@Override
protected void onRequest(long n) {
supplier.get().addListener(new FutureListener<T>() {
@Override
public void operationComplete(Future<T> future) throws Exception {
if (!future.isSuccess()) {
onError(future.cause());
return;
}
if (future.getNow() != null) {
onNext(future.getNow());
}
onComplete();
}
});
}
});
} catch (Throwable throwable) {
//Exceptions.throwIfFatal(throwable);
Exceptions.getFinalCause(throwable);
subscriber.onError(throwable);
}
}
示例8: wrapSubscriber
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
public static <T> Subscriber<T> wrapSubscriber(Subscriber<T> subscriber, IRxBusQueue isResumedProvider)
{
return new Subscriber<T>()
{
@Override
public void onSubscribe(Subscription s) {
subscriber.onSubscribe(s);
}
@Override
public void onComplete()
{
subscriber.onComplete();
}
@Override
public void onError(Throwable e)
{
subscriber.onError(e);
}
@Override
public void onNext(T t)
{
if (RxUtil.safetyQueueCheck(t, isResumedProvider))
subscriber.onNext(t);
}
};
}
示例9: wrapSubscriber
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
public static <T> Subscriber<T> wrapSubscriber(Subscriber<T> subscriber, IRxBusQueue isResumedProvider)
{
return new Subscriber<T>()
{
@Override
public void onSubscribe(Subscription s) {
subscriber.onSubscribe(s);
}
@Override
public void onComplete()
{
subscriber.onComplete();
}
@Override
public void onError(Throwable e)
{
subscriber.onError(e);
}
@Override
public void onNext(T t)
{
if (RxUtil.safetyQueueCheck(t, isResumedProvider))
subscriber.onNext(t);
}
};
}
示例10: onNext
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
/**
* Emits the given value if possible and terminates if there was an onComplete or onError
* while emitting, drops the value otherwise.
* @param <T> the value type
* @param subscriber the target Subscriber to emit to
* @param value the value to emit
* @param wip the serialization work-in-progress counter/indicator
* @param error the holder of Throwables
*/
public static <T> void onNext(Subscriber<? super T> subscriber, T value,
AtomicInteger wip, AtomicThrowable error) {
if (wip.get() == 0 && wip.compareAndSet(0, 1)) {
subscriber.onNext(value);
if (wip.decrementAndGet() != 0) {
Throwable ex = error.terminate();
if (ex != null) {
subscriber.onError(ex);
} else {
subscriber.onComplete();
}
}
}
}
示例11: onError
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
/**
* Emits the given exception if possible or adds it to the given error container to
* be emitted by a concurrent onNext if one is running.
* Undeliverable exceptions are sent to the RxJavaCommonPlugins.onError.
* @param subscriber the target Subscriber to emit to
* @param ex the Throwable to emit
* @param wip the serialization work-in-progress counter/indicator
* @param error the holder of Throwables
*/
public static void onError(Subscriber<?> subscriber, Throwable ex,
AtomicInteger wip, AtomicThrowable error) {
if (error.addThrowable(ex)) {
if (wip.getAndIncrement() == 0) {
subscriber.onError(error.terminate());
}
} else {
RxJavaCommonPlugins.onError(ex);
}
}
示例12: onComplete
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
/**
* Emits an onComplete signal or an onError signal with the given error or indicates
* the concurrently running onNext should do that.
* @param subscriber the target Subscriber to emit to
* @param wip the serialization work-in-progress counter/indicator
* @param error the holder of Throwables
*/
public static void onComplete(Subscriber<?> subscriber, AtomicInteger wip, AtomicThrowable error) {
if (wip.getAndIncrement() == 0) {
Throwable ex = error.terminate();
if (ex != null) {
subscriber.onError(ex);
} else {
subscriber.onComplete();
}
}
}
示例13: fastPathEmitMax
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
protected final void fastPathEmitMax(U value, boolean delayError, Disposable dispose) {
final Subscriber<? super V> s = actual;
final SimplePlainQueue<U> q = queue;
if (wip.get() == 0 && wip.compareAndSet(0, 1)) {
long r = requested.get();
if (r != 0L) {
if (accept(s, value)) {
if (r != Long.MAX_VALUE) {
produced(1);
}
}
if (leave(-1) == 0) {
return;
}
} else {
dispose.dispose();
s.onError(new MissingBackpressureException("Could not emit buffer due to lack of requests"));
return;
}
} else {
q.offer(value);
if (!enter()) {
return;
}
}
QueueDrainHelper.drainMaxLoop(q, s, delayError, dispose, this);
}
示例14: fastPathOrderedEmitMax
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
protected final void fastPathOrderedEmitMax(U value, boolean delayError, Disposable dispose) {
final Subscriber<? super V> s = actual;
final SimplePlainQueue<U> q = queue;
if (wip.get() == 0 && wip.compareAndSet(0, 1)) {
long r = requested.get();
if (r != 0L) {
if (q.isEmpty()) {
if (accept(s, value)) {
if (r != Long.MAX_VALUE) {
produced(1);
}
}
if (leave(-1) == 0) {
return;
}
} else {
q.offer(value);
}
} else {
cancelled = true;
dispose.dispose();
s.onError(new MissingBackpressureException("Could not emit buffer due to lack of requests"));
return;
}
} else {
q.offer(value);
if (!enter()) {
return;
}
}
QueueDrainHelper.drainMaxLoop(q, s, delayError, dispose, this);
}
示例15: subscribe
import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
public void subscribe(Subscriber<? super Object>[] subscribers) {
TestException ex = new TestException();
for (Subscriber<? super Object> s : subscribers) {
EmptySubscription.error(ex, s);
s.onError(ex);
s.onNext(0);
s.onComplete();
s.onComplete();
}
}