當前位置: 首頁>>代碼示例>>Java>>正文


Java Subscriber.onError方法代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:jetty-project,項目名稱:jetty-reactive-httpclient,代碼行數:20,代碼來源:AbstractEventPublisher.java

示例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();
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:24,代碼來源:FlowableFromArray.java

示例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);
    }
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:22,代碼來源:FlowableFromFuture.java

示例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);
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:17,代碼來源:FlowableFromCallable.java

示例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();
                }
            };
        }
    };
}
 
開發者ID:PacktPublishing,項目名稱:Learning-RxJava,代碼行數:37,代碼來源:Ch9_9.java

示例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();
        }
    };
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:30,代碼來源:SubscribeOnlyOnceFlowableOperator.java

示例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);
     }
 }
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:30,代碼來源:NettyFuturePublisher.java

示例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);
        }
    };
}
 
開發者ID:MFlisar,項目名稱:RxBus2,代碼行數:30,代碼來源:RxSubscriptionUtil.java

示例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);
        }
    };
}
 
開發者ID:MFlisar,項目名稱:RxBus2,代碼行數:31,代碼來源:RxBusUtil.java

示例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();
            }
        }
    }
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:24,代碼來源:HalfSerializer.java

示例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);
    }
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:20,代碼來源:HalfSerializer.java

示例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();
        }
    }
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:18,代碼來源:HalfSerializer.java

示例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);
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:29,代碼來源:QueueDrainSubscriber.java

示例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);
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:34,代碼來源:QueueDrainSubscriber.java

示例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();
    }
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:12,代碼來源:ParallelInvalid.java


注:本文中的org.reactivestreams.Subscriber.onError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。