Java Code Examples for reactor.core.Exceptions#terminate()
The following examples show how to use
reactor.core.Exceptions#terminate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FluxSampleTimeout.java From reactor-core with Apache License 2.0 | 6 votes |
boolean checkTerminated(boolean d, boolean empty, Subscriber<?> a, Queue<SampleTimeoutOther<T, U>> q) { if (cancelled) { Operators.onDiscardQueueWithClear(q, ctx, SampleTimeoutOther::toStream); return true; } if (d) { Throwable e = Exceptions.terminate(ERROR, this); if (e != null && e != Exceptions.TERMINATED) { cancel(); Operators.onDiscardQueueWithClear(q, ctx, SampleTimeoutOther::toStream); a.onError(e); return true; } else if (empty) { a.onComplete(); return true; } } return false; }
Example 2
Source File: FluxCombineLatest.java From reactor-core with Apache License 2.0 | 6 votes |
boolean checkTerminated(boolean d, boolean empty, Queue<SourceAndArray> q) { if (cancelled) { cancelAll(); discardQueue(q); return true; } if (d) { Throwable e = Exceptions.terminate(ERROR, this); if (e != null && e != Exceptions.TERMINATED) { cancelAll(); discardQueue(q); actual.onError(e); return true; } else if (empty) { cancelAll(); actual.onComplete(); return true; } } return false; }
Example 3
Source File: FluxConcatMap.java From reactor-core with Apache License 2.0 | 6 votes |
@Override public void innerError(Throwable e) { e = Operators.onNextInnerError(e, currentContext(), s); if(e != null) { if (Exceptions.addThrowable(ERROR, this, e)) { s.cancel(); if (GUARD.getAndIncrement(this) == 0) { e = Exceptions.terminate(ERROR, this); if (e != TERMINATED) { actual.onError(e); } } } else { Operators.onErrorDropped(e, this.ctx); } } else { active = false; drain(); } }
Example 4
Source File: FluxSwitchMap.java From reactor-core with Apache License 2.0 | 6 votes |
boolean checkTerminated(boolean d, boolean empty, Subscriber<?> a, Queue<?> q) { if (cancelled) { cancelAndCleanup(q); return true; } if (d) { Throwable e = Exceptions.terminate(ERROR, this); if (e != null && e != Exceptions.TERMINATED) { cancelAndCleanup(q); a.onError(e); return true; } else if (empty) { a.onComplete(); return true; } } return false; }
Example 5
Source File: FluxConcatMap.java From reactor-core with Apache License 2.0 | 6 votes |
@Override public void onError(Throwable t) { if (Exceptions.addThrowable(ERROR, this, t)) { inner.cancel(); if (GUARD.getAndIncrement(this) == 0) { t = Exceptions.terminate(ERROR, this); if (t != TERMINATED) { actual.onError(t); Operators.onDiscardQueueWithClear(queue, this.ctx, null); } } } else { Operators.onErrorDropped(t, this.ctx); } }
Example 6
Source File: FluxWindowPredicate.java From reactor-core with Apache License 2.0 | 5 votes |
void signalAsyncError() { Throwable e = Exceptions.terminate(ERROR, this); windowCount = 0; WindowFlux<T> g = window; if (g != null) { g.onError(e); } actual.onError(e); window = null; }
Example 7
Source File: FluxSampleFirst.java From reactor-core with Apache License 2.0 | 5 votes |
void handleTermination() { Throwable e = Exceptions.terminate(ERROR, this); if (e != null && e != Exceptions.TERMINATED) { actual.onError(e); } else { actual.onComplete(); } }
Example 8
Source File: FluxConcatMap.java From reactor-core with Apache License 2.0 | 5 votes |
@Override public void innerNext(R value) { if (guard == 0 && GUARD.compareAndSet(this, 0, 1)) { actual.onNext(value); if (GUARD.compareAndSet(this, 1, 0)) { return; } Throwable e = Exceptions.terminate(ERROR, this); if (e != TERMINATED) { actual.onError(e); } } }
Example 9
Source File: FluxGroupJoin.java From reactor-core with Apache License 2.0 | 5 votes |
void errorAll(Subscriber<?> a) { Throwable ex = Exceptions.terminate(ERROR, this); for (FluxIdentityProcessor<TRight> up : lefts.values()) { up.onError(ex); } lefts.clear(); rights.clear(); a.onError(ex); }
Example 10
Source File: FluxGroupBy.java From reactor-core with Apache License 2.0 | 5 votes |
void signalAsyncError() { Throwable e = Exceptions.terminate(ERROR, this); //TODO investigate if e == null if (e == null) { e = new IllegalStateException("FluxGroupBy.signalAsyncError called without error set"); } groupCount = 0; for (UnicastGroupedFlux<K, V> g : groupMap.values()) { g.onError(e); } actual.onError(e); groupMap.clear(); }
Example 11
Source File: StrictSubscriber.java From reactor-core with Apache License 2.0 | 5 votes |
@Override public void onComplete() { done = true; if (WIP.getAndIncrement(this) == 0) { Throwable ex = Exceptions.terminate(ERROR, this); if (ex != null) { actual.onError(ex); } else { actual.onComplete(); } } }
Example 12
Source File: StrictSubscriber.java From reactor-core with Apache License 2.0 | 5 votes |
@Override public void onNext(T t) { if (WIP.get(this) == 0 && WIP.compareAndSet(this, 0, 1)) { actual.onNext(t); if (WIP.decrementAndGet(this) != 0) { Throwable ex = Exceptions.terminate(ERROR, this); if (ex != null) { actual.onError(ex); } else { actual.onComplete(); } } } }
Example 13
Source File: FluxJoin.java From reactor-core with Apache License 2.0 | 5 votes |
void errorAll(Subscriber<?> a) { Throwable ex = Exceptions.terminate(ERROR, this); lefts.clear(); rights.clear(); a.onError(ex); }
Example 14
Source File: FluxWindowBoundary.java From reactor-core with Apache License 2.0 | 4 votes |
void drain() { if (WIP.getAndIncrement(this) != 0) { return; } final Subscriber<? super Flux<T>> a = actual; final Queue<Object> q = queue; FluxIdentityProcessor<T> w = window; int missed = 1; for (;;) { for (;;) { if (error != null) { q.clear(); Throwable e = Exceptions.terminate(ERROR, this); if (e != Exceptions.TERMINATED) { w.onError(e); a.onError(e); } return; } Object o = q.poll(); if (o == null) { break; } if (o == DONE) { q.clear(); w.onComplete(); a.onComplete(); return; } if (o != BOUNDARY_MARKER) { @SuppressWarnings("unchecked") T v = (T)o; w.onNext(v); } if (o == BOUNDARY_MARKER) { w.onComplete(); if (cancelled == 0) { if (requested != 0L) { Queue<T> pq = processorQueueSupplier.get(); WINDOW_COUNT.getAndIncrement(this); w = Processors.more().unicast(pq, this); window = w; a.onNext(w); if (requested != Long.MAX_VALUE) { REQUESTED.decrementAndGet(this); } } else { q.clear(); cancelMain(); boundary.cancel(); a.onError(Exceptions.failWithOverflow("Could not create new window due to lack of requests")); return; } } } } missed = WIP.addAndGet(this, -missed); if (missed == 0) { break; } } }
Example 15
Source File: FluxCombineLatest.java From reactor-core with Apache License 2.0 | 4 votes |
void drainAsync() { final Queue<SourceAndArray> q = queue; int missed = 1; for (; ; ) { long r = requested; long e = 0L; while (e != r) { boolean d = done; SourceAndArray v = q.poll(); boolean empty = v == null; if (checkTerminated(d, empty, q)) { return; } if (empty) { break; } R w; try { w = Objects.requireNonNull(combiner.apply(v.array), "Combiner returned null"); } catch (Throwable ex) { Context ctx = actual.currentContext(); Operators.onDiscardMultiple(Stream.of(v.array), ctx); ex = Operators.onOperatorError(this, ex, v.array, ctx); Exceptions.addThrowable(ERROR, this, ex); //noinspection ConstantConditions ex = Exceptions.terminate(ERROR, this); actual.onError(ex); return; } actual.onNext(w); v.source.requestOne(); e++; } if (e == r) { if (checkTerminated(done, q.isEmpty(), q)) { return; } } if (e != 0L && r != Long.MAX_VALUE) { REQUESTED.addAndGet(this, -e); } missed = WIP.addAndGet(this, -missed); if (missed == 0) { break; } } }
Example 16
Source File: FluxSampleTimeout.java From reactor-core with Apache License 2.0 | 4 votes |
void drain() { if (WIP.getAndIncrement(this) != 0) { return; } final Subscriber<? super T> a = actual; final Queue<SampleTimeoutOther<T, U>> q = queue; int missed = 1; for (; ; ) { for (; ; ) { boolean d = done; SampleTimeoutOther<T, U> o = q.poll(); boolean empty = o == null; if (checkTerminated(d, empty, a, q)) { return; } if (empty) { break; } if (o.index == index) { long r = requested; if (r != 0) { a.onNext(o.value); if (r != Long.MAX_VALUE) { REQUESTED.decrementAndGet(this); } } else { cancel(); Operators.onDiscardQueueWithClear(q, ctx, SampleTimeoutOther::toStream); Throwable e = Exceptions.failWithOverflow( "Could not emit value due to lack of requests"); Exceptions.addThrowable(ERROR, this, e); e = Exceptions.terminate(ERROR, this); a.onError(e); return; } } } missed = WIP.addAndGet(this, -missed); if (missed == 0) { break; } } }
Example 17
Source File: FluxConcatArray.java From reactor-core with Apache License 2.0 | 4 votes |
@Override public void onComplete() { if (WIP.getAndIncrement(this) == 0) { Publisher<? extends T>[] a = sources; do { if (isCancelled()) { return; } int i = index; if (i == a.length) { Throwable e = Exceptions.terminate(ERROR, this); if (e != null) { actual.onError(e); } else { actual.onComplete(); } return; } Publisher<? extends T> p = a[i]; if (p == null) { actual.onError(new NullPointerException("Source Publisher at index " + i + " is null")); return; } long c = produced; if (c != 0L) { produced = 0L; produced(c); } p.subscribe(this); if (isCancelled()) { return; } index = ++i; } while (WIP.decrementAndGet(this) != 0); } }