本文整理汇总了Java中reactor.core.CoreSubscriber.onError方法的典型用法代码示例。如果您正苦于以下问题:Java CoreSubscriber.onError方法的具体用法?Java CoreSubscriber.onError怎么用?Java CoreSubscriber.onError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reactor.core.CoreSubscriber
的用法示例。
在下文中一共展示了CoreSubscriber.onError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
Operators.MonoSubscriber<T, T>
sds = new Operators.MonoSubscriber<>(actual);
actual.onSubscribe(sds);
if (sds.isCancelled()) {
return;
}
try {
T t = callable.call();
if (t == null) {
sds.onComplete();
}
else {
sds.complete(t);
}
}
catch (Throwable e) {
actual.onError(Operators.onOperatorError(e, actual.currentContext()));
}
}
示例2: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
Operators.MonoSubscriber<T, T>
sds = new Operators.MonoSubscriber<>(actual);
actual.onSubscribe(sds);
if (sds.isCancelled()) {
return;
}
try {
T t = supplier.get();
if (t == null) {
sds.onComplete();
}
else {
sds.complete(t);
}
}
catch (Throwable e) {
actual.onError(Operators.onOperatorError(e, actual.currentContext()));
}
}
示例3: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
Operators.MonoSubscriber<T, T> wrapper = new Operators.MonoSubscriber<>(actual);
actual.onSubscribe(wrapper);
try {
T v = callable.call();
if (v == null) {
wrapper.onComplete();
}
else {
wrapper.complete(v);
}
}
catch (Throwable ex) {
actual.onError(Operators.onOperatorError(ex, actual.currentContext()));
}
}
示例4: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
T v = value;
if (v == null) {
ScheduledEmpty parent = new ScheduledEmpty(actual);
actual.onSubscribe(parent);
try {
parent.setFuture(scheduler.schedule(parent));
}
catch (RejectedExecutionException ree) {
if (parent.future != OperatorDisposables.DISPOSED) {
actual.onError(Operators.onRejectedExecution(ree,
actual.currentContext()));
}
}
}
else {
actual.onSubscribe(new ScheduledScalar<>(actual, v, scheduler));
}
}
示例5: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
Scheduler.Worker worker = scheduler.createWorker();
SubscribeOnSubscriber<T> parent = new SubscribeOnSubscriber<>(source,
actual, worker);
actual.onSubscribe(parent);
try {
worker.schedule(parent);
}
catch (RejectedExecutionException ree) {
if (parent.s != Operators.cancelledSubscription()) {
actual.onError(Operators.onRejectedExecution(ree, parent, null, null,
actual.currentContext()));
}
}
}
示例6: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
CallableSubscribeOnSubscription<T> parent =
new CallableSubscribeOnSubscription<>(actual, callable, scheduler);
actual.onSubscribe(parent);
try {
Disposable f = scheduler.schedule(parent);
parent.setMainFuture(f);
}
catch (RejectedExecutionException ree) {
if(parent.state != CallableSubscribeOnSubscription.HAS_CANCELLED) {
actual.onError(Operators.onRejectedExecution(ree, actual.currentContext()));
}
}
}
示例7: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
Objects.requireNonNull(actual, "subscribe");
DirectInner<T> p = new DirectInner<>(actual, this);
actual.onSubscribe(p);
if (add(p)) {
if (p.cancelled) {
remove(p);
}
}
else {
Throwable e = error;
if (e != null) {
actual.onError(e);
}
else {
actual.onComplete();
}
}
}
示例8: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super Long> actual) {
Worker w = timedScheduler.createWorker();
IntervalRunnable r = new IntervalRunnable(actual, w);
actual.onSubscribe(r);
try {
w.schedulePeriodically(r, initialDelay, period, unit);
}
catch (RejectedExecutionException ree) {
if (!r.cancelled) {
actual.onError(Operators.onRejectedExecution(ree, r, null, null,
actual.currentContext()));
}
}
}
示例9: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
PublishMulticastInner<T> pcs = new PublishMulticastInner<>(this, actual);
actual.onSubscribe(pcs);
if (add(pcs)) {
if (pcs.requested == Long.MIN_VALUE) {
remove(pcs);
return;
}
drain();
}
else {
Throwable ex = error;
if (ex != null) {
actual.onError(ex);
}
else {
actual.onComplete();
}
}
}
示例10: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super Long> actual) {
MonoDelayRunnable r = new MonoDelayRunnable(actual);
actual.onSubscribe(r);
try {
r.setCancel(timedScheduler.schedule(r, delay, unit));
}
catch (RejectedExecutionException ree) {
if(r.cancel != OperatorDisposables.DISPOSED) {
actual.onError(Operators.onRejectedExecution(ree, r, null, null,
actual.currentContext()));
}
}
}
示例11: apply
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public CoreSubscriber<? super T> apply(Scannable scannable, CoreSubscriber<? super T> coreSubscriber) {
return new CoreSubscriber<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 Flux.share() instead.");
} else {
coreSubscriber.onSubscribe(subscription);
}
}
@Override
public void onNext(T t) {
coreSubscriber.onNext(t);
}
@Override
public void onError(Throwable throwable) {
coreSubscriber.onError(throwable);
}
@Override
public void onComplete() {
coreSubscriber.onComplete();
}
};
}
示例12: terminateReceiver
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
final void terminateReceiver(Queue<?> q, CoreSubscriber<?> a) {
if (q != null) {
q.clear();
}
Throwable ex = inboundError;
if (ex != null) {
parent.context.fireContextError(ex);
a.onError(ex);
}
else {
a.onComplete();
}
}
示例13: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
if (once == 0 && ONCE.compareAndSet(this, 0, 1)) {
actual.onSubscribe(this);
ACTUAL.lazySet(this, actual);
drain();
}
else {
actual.onError(new IllegalStateException(
"This processor allows only a single Subscriber"));
}
}
示例14: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
void subscribe(Publisher<? extends T>[] sources,
int n,
CoreSubscriber<? super T> actual) {
FirstEmittingSubscriber<T>[] a = subscribers;
for (int i = 0; i < n; i++) {
a[i] = new FirstEmittingSubscriber<>(actual, this, i);
}
actual.onSubscribe(this);
for (int i = 0; i < n; i++) {
if (cancelled || wip != Integer.MIN_VALUE) {
return;
}
Publisher<? extends T> p = sources[i];
if (p == null) {
if (WIP.compareAndSet(this, Integer.MIN_VALUE, -1)) {
actual.onError(new NullPointerException("The " + i + " th Publisher source is null"));
}
return;
}
p.subscribe(a[i]);
}
}
示例15: postCompleteDelayError
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
/**
* Tries draining the queue if the source just completed.
*
* @param <T> the output value type
* @param <F> the field type holding the requested amount
* @param actual the consumer of values
* @param queue the queue of available values
* @param field the field updater for the requested amount
* @param instance the parent instance of the requested field
* @param isCancelled callback to detect cancellation
* @param error if not null, the error to signal after the queue has been drained
*/
public static <T, F> void postCompleteDelayError(CoreSubscriber<? super T> actual,
Queue<T> queue,
AtomicLongFieldUpdater<F> field,
F instance,
BooleanSupplier isCancelled,
@Nullable Throwable error) {
if (queue.isEmpty()) {
if (error == null) {
actual.onComplete();
} else {
actual.onError(error);
}
return;
}
if (postCompleteDrainDelayError(field.get(instance), actual, queue, field, instance, isCancelled, error)) {
return;
}
for (; ; ) {
long r = field.get(instance);
if ((r & COMPLETED_MASK) != 0L) {
return;
}
long u = r | COMPLETED_MASK;
// (active, r) -> (complete, r) transition
if (field.compareAndSet(instance, r, u)) {
// if the requested amount was non-zero, drain the queue
if (r != 0L) {
postCompleteDrainDelayError(u, actual, queue, field, instance, isCancelled, error);
}
return;
}
}
}