当前位置: 首页>>代码示例>>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;未经允许,请勿转载。