@Override public void onError(Throwable t) { if (MAIN.compareAndSet(this, null, Operators.cancelledSubscription())) { Operators.error(actual, t); return; } else if (main == Operators.cancelledSubscription()){ Operators.onErrorDropped(t, actual.currentContext()); return; } cancel(); actual.onError(t); }
@Override public void subscribe(CoreSubscriber<? super T> actual) { Throwable error = Objects.requireNonNull(errorSupplier.get(), "the errorSupplier returned null"); Operators.error(actual, Operators.onOperatorError(error, actual.currentContext())); }
@Override public void subscribe(CoreSubscriber<? super T> actual) { try { run.run(); } catch (Throwable ex) { Operators.error(actual, Operators.onOperatorError(ex, actual.currentContext())); return; } Operators.complete(actual); }
@Override public void onError(Throwable t) { if (done) { Operators.onErrorDropped(t, this.ctx); return; } done = true; actual.onError(t); Operators.onDiscardMultiple(buffer, this.ctx); }
@Override void request(WriteResultPublisher publisher, long n) { Operators.validate(n); } },
void cancelOther() { Subscription s = other; if (s != Operators.cancelledSubscription()) { s = OTHER.getAndSet(this, Operators.cancelledSubscription()); if (s != null && s != Operators.cancelledSubscription()) { s.cancel(); } } }
@Override public void onError(Throwable t) { if (subscription != Operators.cancelledSubscription()) { SUBSCRIPTION.lazySet(this, Operators.cancelledSubscription()); parent.boundaryError(this, t); } else { Operators.onErrorDropped(t, parent.ctx); } }
@Override public void onError(Throwable t) { if (done) { Operators.onErrorDropped(t, ctx); return; } error = t; done = true; drain(); }
@Override public void onError(Throwable t) { if (main == null) { if (MAIN.compareAndSet(this, null, Operators.cancelledSubscription())) { Operators.error(actual, t); return; } } cancel(); actual.onError(t); }
@Override public void onComplete() { if (main == null) { if (MAIN.compareAndSet(this, null, Operators.cancelledSubscription())) { cancelOther(); Operators.complete(actual); return; } } cancel(); actual.onComplete(); } }
boolean failOverflow(R v, Subscription toCancel){ Throwable e = Operators.onOperatorError(toCancel, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), v, actual.currentContext()); if (!Exceptions.addThrowable(ERROR, this, e)) { Operators.onErrorDropped(e, actual.currentContext()); return false; } return true; }
@Override public void subscribe(CoreSubscriber<? super T> actual) { if (state == STATE_INIT && STATE.compareAndSet(this, STATE_INIT, STATE_SUBSCRIBED_ONCE)) { if (first == null && done) { if (throwable != null) { Operators.error(actual, throwable); } else { Operators.complete(actual); } return; } INNER.lazySet(this, Operators.toConditionalSubscriber(actual)); actual.onSubscribe(this); } else { Operators.error(actual, new IllegalStateException("FluxSwitchOnFirst allows only one Subscriber")); } }
@Override public void subscribe(CoreSubscriber<? super T> actual) { if (state == STATE_INIT && STATE.compareAndSet(this, STATE_INIT, STATE_SUBSCRIBED_ONCE)) { if (first == null && done) { if (throwable != null) { Operators.error(actual, throwable); } else { Operators.complete(actual); } return; } INNER.lazySet(this, actual); actual.onSubscribe(this); } else { Operators.error(actual, new IllegalStateException("FluxSwitchOnFirst allows only one Subscriber")); } }
@Override public void onError(Throwable e) { done = true; Throwable e_ = Operators.onOperatorError(e, parent.currentContext()); Throwable commitError = new RuntimeException("Async resource cleanup failed after onComplete", e_); parent.deferredError(commitError); }
@Override public void onSubscribe(Subscription s) { if (!MAIN.compareAndSet(this, null, s)) { s.cancel(); if (main != Operators.cancelledSubscription()) { Operators.reportSubscriptionSet(); } return; } s.request(Long.MAX_VALUE); }
@Test public void scanProcessorError() { MonoProcessor<String> test = MonoProcessor.create(); Subscription subscription = Operators.emptySubscription(); test.onSubscribe(subscription); test.onError(new IllegalStateException("boom")); assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom"); assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); }
@Override public final void onSubscribe(Subscription s) { if (Operators.setOnce(S, this, s)) { try { hookOnSubscribe(s); } catch (Throwable throwable) { onError(Operators.onOperatorError(s, throwable, currentContext())); } } }
@Override public void onNext(T t) { if (!queue.offer(t)) { Operators.terminate(S, this); onError(Operators.onOperatorError(null, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t, currentContext())); } else { signalConsumer(); } }