From e0b04b4b4f05dc90d587c6159557ac7f60a3d131 Mon Sep 17 00:00:00 2001 From: Stephane Maldini Date: Wed, 30 Aug 2017 17:52:50 -0700 Subject: [PATCH 1/5] Contextualize Operators.onErrorDropped and onNextDropped - remove unused Operators.onErrorDropped(error, supp) - add few missing Operators.onNextDropped --- .../core/publisher/BaseSubscriber.java | 8 +-- .../core/publisher/EmitterProcessor.java | 1 + .../reactor/core/publisher/FluxBuffer.java | 12 ++--- .../core/publisher/FluxBufferBoundary.java | 6 +-- .../core/publisher/FluxBufferPredicate.java | 4 +- .../core/publisher/FluxBufferWhen.java | 6 +-- .../core/publisher/FluxCombineLatest.java | 2 +- .../core/publisher/FluxConcatArray.java | 2 +- .../reactor/core/publisher/FluxConcatMap.java | 8 +-- .../reactor/core/publisher/FluxCreate.java | 8 ++- .../core/publisher/FluxDelaySubscription.java | 2 +- .../core/publisher/FluxDematerialize.java | 4 +- .../reactor/core/publisher/FluxDistinct.java | 14 ++--- .../publisher/FluxDistinctUntilChanged.java | 8 +-- .../reactor/core/publisher/FluxDoFinally.java | 4 +- .../core/publisher/FluxDoFinallyFuseable.java | 2 +- .../reactor/core/publisher/FluxDoOnEach.java | 5 +- .../reactor/core/publisher/FluxFilter.java | 12 ++--- .../core/publisher/FluxFilterFuseable.java | 12 ++--- .../core/publisher/FluxFilterWhen.java | 2 +- .../reactor/core/publisher/FluxFlatMap.java | 13 ++--- .../core/publisher/FluxFlattenIterable.java | 2 +- .../reactor/core/publisher/FluxGenerate.java | 4 +- .../reactor/core/publisher/FluxGroupBy.java | 4 +- .../reactor/core/publisher/FluxGroupJoin.java | 4 +- .../reactor/core/publisher/FluxHandle.java | 12 ++--- .../core/publisher/FluxHandleFuseable.java | 12 ++--- .../java/reactor/core/publisher/FluxJoin.java | 4 +- .../java/reactor/core/publisher/FluxMap.java | 10 ++-- .../core/publisher/FluxMapFuseable.java | 10 ++-- .../reactor/core/publisher/FluxMapSignal.java | 4 +- .../core/publisher/FluxMaterialize.java | 4 +- .../core/publisher/FluxMergeSequential.java | 4 +- .../publisher/FluxOnBackpressureBuffer.java | 4 +- .../FluxOnBackpressureBufferStrategy.java | 4 +- .../FluxOnBackpressureBufferTimeout.java | 2 +- .../publisher/FluxOnBackpressureDrop.java | 4 +- .../java/reactor/core/publisher/FluxPeek.java | 22 ++++---- .../core/publisher/FluxPeekFuseable.java | 28 +++++----- .../core/publisher/FluxPublishMulticast.java | 8 +-- .../reactor/core/publisher/FluxPublishOn.java | 8 +-- .../core/publisher/FluxSampleFirst.java | 2 +- .../core/publisher/FluxSampleTimeout.java | 6 +-- .../java/reactor/core/publisher/FluxScan.java | 4 +- .../reactor/core/publisher/FluxScanSeed.java | 4 +- .../reactor/core/publisher/FluxSkipUntil.java | 6 +-- .../core/publisher/FluxSkipUntilOther.java | 4 +- .../reactor/core/publisher/FluxSkipWhile.java | 6 +-- .../reactor/core/publisher/FluxSwitchMap.java | 8 +-- .../java/reactor/core/publisher/FluxTake.java | 14 ++--- .../reactor/core/publisher/FluxTakeUntil.java | 4 +- .../reactor/core/publisher/FluxTakeWhile.java | 4 +- .../reactor/core/publisher/FluxTimeout.java | 8 +-- .../reactor/core/publisher/FluxUsing.java | 6 +-- .../reactor/core/publisher/FluxWindow.java | 12 ++--- .../core/publisher/FluxWindowBoundary.java | 6 +-- .../core/publisher/FluxWindowPredicate.java | 4 +- .../core/publisher/FluxWindowWhen.java | 6 +-- .../java/reactor/core/publisher/FluxZip.java | 10 ++-- .../core/publisher/FluxZipIterable.java | 4 +- .../java/reactor/core/publisher/MonoAll.java | 2 +- .../java/reactor/core/publisher/MonoAny.java | 2 +- .../reactor/core/publisher/MonoCacheTime.java | 2 +- .../reactor/core/publisher/MonoCollect.java | 4 +- .../reactor/core/publisher/MonoCreate.java | 2 +- .../core/publisher/MonoDelayElement.java | 4 +- .../reactor/core/publisher/MonoDoFinally.java | 2 +- .../core/publisher/MonoDoFinallyFuseable.java | 2 +- .../reactor/core/publisher/MonoElementAt.java | 4 +- .../core/publisher/MonoFilterWhen.java | 2 +- .../reactor/core/publisher/MonoFlatMap.java | 8 +-- .../core/publisher/MonoFlatMapMany.java | 2 +- .../core/publisher/MonoIgnoreThen.java | 4 +- .../java/reactor/core/publisher/MonoNext.java | 4 +- .../core/publisher/MonoPeekTerminal.java | 21 +++++--- .../reactor/core/publisher/MonoReduce.java | 4 +- .../core/publisher/MonoReduceSeed.java | 2 +- .../reactor/core/publisher/MonoSingle.java | 4 +- .../core/publisher/MonoStreamCollector.java | 4 +- .../publisher/MonoToCompletableFuture.java | 1 - .../reactor/core/publisher/Operators.java | 53 +++++++++++-------- .../core/publisher/ParallelCollect.java | 4 +- .../core/publisher/ParallelMergeReduce.java | 6 +-- .../publisher/ParallelMergeSequential.java | 2 +- .../core/publisher/ParallelMergeSort.java | 2 +- .../core/publisher/ParallelReduceSeed.java | 4 +- .../core/publisher/ParallelSource.java | 4 +- .../core/publisher/ReplayProcessor.java | 1 - .../core/publisher/UnicastProcessor.java | 4 +- 89 files changed, 293 insertions(+), 274 deletions(-) diff --git a/reactor-core/src/main/java/reactor/core/publisher/BaseSubscriber.java b/reactor-core/src/main/java/reactor/core/publisher/BaseSubscriber.java index 286208f58b..2b326d2514 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/BaseSubscriber.java +++ b/reactor-core/src/main/java/reactor/core/publisher/BaseSubscriber.java @@ -129,7 +129,7 @@ protected void hookOnCancel() { * cancel). The hook is executed in addition to and after {@link #hookOnError(Throwable)}, * {@link #hookOnComplete()} and {@link #hookOnCancel()} hooks, even if these callbacks * fail. Defaults to doing nothing. A failure of the callback will be caught by - * {@link Operators#onErrorDropped(Throwable)}. + * {@link Operators#onErrorDropped(Throwable, reactor.util.context.Context)}. * * @param type the type of termination event that triggered the hook * ({@link SignalType#ON_ERROR}, {@link SignalType#ON_COMPLETE} or @@ -169,7 +169,7 @@ public final void onError(Throwable t) { if (S.getAndSet(this, Operators.cancelledSubscription()) == Operators .cancelledSubscription()) { //already cancelled concurrently - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, currentContext()); return; } @@ -181,7 +181,7 @@ public final void onError(Throwable t) { if (e != t) { e.addSuppressed(t); } - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, currentContext()); } finally { safeHookFinally(SignalType.ON_ERROR); @@ -243,7 +243,7 @@ void safeHookFinally(SignalType type) { hookFinally(type); } catch (Throwable finallyFailure) { - Operators.onErrorDropped(finallyFailure); + Operators.onErrorDropped(finallyFailure, currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java index 3f0b4dcac1..2aa67dbb6f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java @@ -228,6 +228,7 @@ else if (m == Fuseable.ASYNC) { @SuppressWarnings("unchecked") public void onNext(T t) { if (done) { + Operators.onNextDropped(t); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBuffer.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBuffer.java index 1c7e8142d9..4081b1100c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBuffer.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBuffer.java @@ -129,7 +129,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -157,7 +157,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -271,7 +271,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -306,7 +306,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } @@ -450,7 +450,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -495,7 +495,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferBoundary.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferBoundary.java index c91b7c2955..7ddc48bb37 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferBoundary.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferBoundary.java @@ -167,7 +167,7 @@ public void onNext(T t) { } } - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); } @Override @@ -181,7 +181,7 @@ public void onError(Throwable t) { actual.onError(t); return; } - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } @Override @@ -242,7 +242,7 @@ void otherError(Throwable t){ actual.onError(t); return; } - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } void otherNext() { diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferPredicate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferPredicate.java index 2517823282..04919b1481 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferPredicate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferPredicate.java @@ -185,7 +185,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return true; } @@ -261,7 +261,7 @@ public CoreSubscriber actual() { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferWhen.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferWhen.java index 12cb44ff7f..f788475d2f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferWhen.java @@ -185,7 +185,7 @@ public void onNext(T t) { } } - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); } @Override @@ -206,7 +206,7 @@ public void onError(Throwable t) { anyError(t); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } } @@ -312,7 +312,7 @@ void anyError(Throwable t) { drain(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxCombineLatest.java b/reactor-core/src/main/java/reactor/core/publisher/FluxCombineLatest.java index d367150304..cea34ba70d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxCombineLatest.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxCombineLatest.java @@ -355,7 +355,7 @@ void innerError(Throwable e) { drain(); } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxConcatArray.java b/reactor-core/src/main/java/reactor/core/publisher/FluxConcatArray.java index 4425fbf976..1cc95616ca 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxConcatArray.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxConcatArray.java @@ -247,7 +247,7 @@ public void onError(Throwable t) { if (Exceptions.addThrowable(ERROR, this, t)) { onComplete(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxConcatMap.java b/reactor-core/src/main/java/reactor/core/publisher/FluxConcatMap.java index cbf3b8c70c..9b78bc0dbb 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxConcatMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxConcatMap.java @@ -254,7 +254,7 @@ public void onError(Throwable t) { } } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } } @@ -297,7 +297,7 @@ public void innerError(Throwable e) { } } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } @@ -584,7 +584,7 @@ public void onError(Throwable t) { drain(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } } @@ -616,7 +616,7 @@ public void innerError(Throwable e) { drain(); } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxCreate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxCreate.java index 95ed5b0f69..7289fde37f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxCreate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxCreate.java @@ -137,6 +137,7 @@ public Context currentContext() { @Override public FluxSink next(T t) { if (sink.isCancelled() || done) { + Operators.onNextDropped(t, sink.currentContext()); return this; } //noinspection ConstantConditions @@ -165,7 +166,7 @@ public FluxSink next(T t) { @Override public void error(Throwable t) { if (sink.isCancelled() || done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, sink.currentContext()); return; } //noinspection ConstantConditions @@ -177,7 +178,7 @@ public void error(Throwable t) { drain(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, sink.currentContext()); } } @@ -418,6 +419,7 @@ public void complete() { @Override public void error(Throwable e) { if (isCancelled()) { + Operators.onErrorDropped(e, actual.currentContext()); return; } try { @@ -567,6 +569,7 @@ static final class IgnoreSink extends BaseSink { @Override public FluxSink next(T t) { if (isCancelled()) { + Operators.onNextDropped(t, actual.currentContext()); return this; } @@ -591,6 +594,7 @@ static abstract class NoOverflowBaseAsyncSink extends BaseSink { @Override public final FluxSink next(T t) { if (isCancelled()) { + Operators.onNextDropped(t, actual.currentContext()); return this; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDelaySubscription.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDelaySubscription.java index bd293d1780..01def6184b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDelaySubscription.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDelaySubscription.java @@ -125,7 +125,7 @@ public void onNext(U t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDematerialize.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDematerialize.java index 83316771e2..e51b7cefe4 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDematerialize.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDematerialize.java @@ -94,7 +94,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(Signal t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } if (t.isOnComplete()) { @@ -119,7 +119,7 @@ else if (t.isOnNext()) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinct.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinct.java index debb437b75..301231ee34 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinct.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinct.java @@ -118,7 +118,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return true; } @@ -153,7 +153,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -230,7 +230,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -266,7 +266,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return true; } @@ -297,7 +297,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -391,7 +391,7 @@ public boolean tryOnNext(T t) { return true; } if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return true; } @@ -426,7 +426,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctUntilChanged.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctUntilChanged.java index f26b7b978b..8fb75c10be 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctUntilChanged.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctUntilChanged.java @@ -96,7 +96,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return true; } @@ -139,7 +139,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -222,7 +222,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return true; } @@ -263,7 +263,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDoFinally.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDoFinally.java index 4de33f1a5d..d2d62684aa 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDoFinally.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDoFinally.java @@ -35,7 +35,7 @@ * {@link SignalType#CANCEL}). *

* Note that any exception thrown by the hook are caught and bubbled up - * using {@link Operators#onErrorDropped(Throwable)}. + * using {@link Operators#onErrorDropped(Throwable, reactor.util.context.Context)}. * * @param the value type * @author Simon Baslé @@ -152,7 +152,7 @@ void runFinally(SignalType signalType) { onFinally.accept(signalType); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); - Operators.onErrorDropped(ex); + Operators.onErrorDropped(ex, actual.currentContext()); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDoFinallyFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDoFinallyFuseable.java index be8b34a6ba..feb53aa75d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDoFinallyFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDoFinallyFuseable.java @@ -29,7 +29,7 @@ * {@link SignalType#CANCEL}). *

* Note that any exception thrown by the hook are caught and bubbled up - * using {@link Operators#onErrorDropped(Throwable)}. + * using {@link Operators#onErrorDropped(Throwable, reactor.util.context.Context)}. * * @param the value type * @author Simon Baslé diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDoOnEach.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDoOnEach.java index a2de39fd7c..5fb168133b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDoOnEach.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDoOnEach.java @@ -17,7 +17,6 @@ package reactor.core.publisher; import java.util.Objects; -import java.util.function.BiConsumer; import java.util.function.Consumer; import javax.annotation.Nullable; @@ -98,7 +97,7 @@ public Object scanUnsafe(Attr key) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } try { @@ -117,7 +116,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFilter.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFilter.java index 0728159157..68bd62d503 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFilter.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFilter.java @@ -80,7 +80,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -104,7 +104,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return false; } @@ -126,7 +126,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -196,7 +196,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -220,7 +220,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return false; } @@ -239,7 +239,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFilterFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFilterFuseable.java index 23b7b464b9..67996d90b2 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFilterFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFilterFuseable.java @@ -88,7 +88,7 @@ public void onNext(T t) { } else { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } boolean b; @@ -112,7 +112,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return false; } @@ -135,7 +135,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -269,7 +269,7 @@ public void onNext(T t) { } else { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } boolean b; @@ -293,7 +293,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return false; } @@ -312,7 +312,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFilterWhen.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFilterWhen.java index bcb5440051..54ae614ec7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFilterWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFilterWhen.java @@ -439,7 +439,7 @@ public void onError(Throwable t) { done = true; parent.innerError(t); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, parent.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFlatMap.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFlatMap.java index 50c432639f..1113a97a5f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFlatMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFlatMap.java @@ -343,7 +343,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -391,7 +391,7 @@ Queue getOrCreateScalarQueue() { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } if (Exceptions.addThrowable(ERROR, this, t)) { @@ -399,7 +399,7 @@ public void onError(Throwable t) { drain(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } } @@ -622,7 +622,8 @@ else if (q != null) { catch (Throwable ex) { ex = Operators.onOperatorError(inner, ex); if (!Exceptions.addThrowable(ERROR, this, ex)) { - Operators.onErrorDropped(ex); + Operators.onErrorDropped(ex, + actual.currentContext()); } v = null; d = true; @@ -790,7 +791,7 @@ void innerError(FlatMapInner inner, Throwable e) { drain(); } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } @@ -800,7 +801,7 @@ boolean failOverflow(R v, Subscription toCancel){ v); if (!Exceptions.addThrowable(ERROR, this, e)) { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); return false; } return true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFlattenIterable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFlattenIterable.java index cf2e623b31..470a36b9b8 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFlattenIterable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFlattenIterable.java @@ -242,7 +242,7 @@ public void onError(Throwable t) { drain(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxGenerate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxGenerate.java index c27208e56e..bdcaaa970e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxGenerate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxGenerate.java @@ -145,7 +145,7 @@ public CoreSubscriber actual() { @Override public void next(T t) { if (terminate) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } if (hasValue) { @@ -306,7 +306,7 @@ void cleanup(S s) { stateConsumer.accept(s); } catch (Throwable e) { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxGroupBy.java b/reactor-core/src/main/java/reactor/core/publisher/FluxGroupBy.java index e6bf0fb0af..33d7569a2b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxGroupBy.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxGroupBy.java @@ -174,7 +174,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if(done){ - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -218,7 +218,7 @@ public void onError(Throwable t) { drain(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxGroupJoin.java b/reactor-core/src/main/java/reactor/core/publisher/FluxGroupJoin.java index 5975b144a4..940b9975c1 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxGroupJoin.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxGroupJoin.java @@ -466,7 +466,7 @@ public void innerError(Throwable ex) { drain(); } else { - Operators.onErrorDropped(ex); + Operators.onErrorDropped(ex, actual.currentContext()); } } @@ -499,7 +499,7 @@ public void innerCloseError(Throwable ex) { drain(); } else { - Operators.onErrorDropped(ex); + Operators.onErrorDropped(ex, actual.currentContext()); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxHandle.java b/reactor-core/src/main/java/reactor/core/publisher/FluxHandle.java index 9676ac295c..aadf390646 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxHandle.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxHandle.java @@ -89,7 +89,7 @@ public Context currentContext() { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -121,7 +121,7 @@ else if(v == null){ @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return false; } @@ -153,7 +153,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } @@ -251,7 +251,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -283,7 +283,7 @@ else if(v == null){ @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return false; } @@ -316,7 +316,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxHandleFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxHandleFuseable.java index 20e2ed0d29..0b5dd868fb 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxHandleFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxHandleFuseable.java @@ -96,7 +96,7 @@ public Context currentContext() { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return true; } @@ -141,7 +141,7 @@ public void onNext(T t) { } else { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } try { @@ -173,7 +173,7 @@ else if (v == null) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } @@ -373,7 +373,7 @@ public void onNext(T t) { } else { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } try { @@ -405,7 +405,7 @@ else if (v == null) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return true; } @@ -438,7 +438,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxJoin.java b/reactor-core/src/main/java/reactor/core/publisher/FluxJoin.java index a7dbd05f86..1efee97fbd 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxJoin.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxJoin.java @@ -478,7 +478,7 @@ public void innerError(Throwable ex) { drain(); } else { - Operators.onErrorDropped(ex); + Operators.onErrorDropped(ex, actual.currentContext()); } } @@ -511,7 +511,7 @@ public void innerCloseError(Throwable ex) { drain(); } else { - Operators.onErrorDropped(ex); + Operators.onErrorDropped(ex, actual.currentContext()); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMap.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMap.java index a5e4fe436d..cbe742a0be 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMap.java @@ -90,7 +90,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -111,7 +111,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } @@ -183,7 +183,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -204,7 +204,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return true; } @@ -226,7 +226,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMapFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMapFuseable.java index 7ccd90e6cf..75690abfff 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMapFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMapFuseable.java @@ -98,7 +98,7 @@ public void onNext(T t) { } else { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } R v; @@ -119,7 +119,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } @@ -248,7 +248,7 @@ public void onNext(T t) { } else { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -270,7 +270,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return true; } @@ -291,7 +291,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMapSignal.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMapSignal.java index 4ab7403186..a71fc9634b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMapSignal.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMapSignal.java @@ -123,7 +123,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -150,7 +150,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMaterialize.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMaterialize.java index 69a4b995f6..484951942f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMaterialize.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMaterialize.java @@ -92,7 +92,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T ev) { if(terminalSignal != null){ - Operators.onNextDropped(ev); + Operators.onNextDropped(ev, actual.currentContext()); return; } produced++; @@ -102,7 +102,7 @@ public void onNext(T ev) { @Override public void onError(Throwable ev) { if(terminalSignal != null){ - Operators.onErrorDropped(ev); + Operators.onErrorDropped(ev, actual.currentContext()); return; } terminalSignal = Signal.error(ev); diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMergeSequential.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMergeSequential.java index 2d95d6ff10..ee58e6238a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMergeSequential.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMergeSequential.java @@ -242,7 +242,7 @@ public void onError(Throwable t) { drain(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } } @@ -307,7 +307,7 @@ void innerError(MergeSequentialInner inner, Throwable e) { drain(); } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBuffer.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBuffer.java index 149c64770b..eeab73cb93 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBuffer.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBuffer.java @@ -142,7 +142,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } if (!queue.offer(t)) { @@ -166,7 +166,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } error = t; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferStrategy.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferStrategy.java index 207f95dd35..eddf6993b0 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferStrategy.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferStrategy.java @@ -132,7 +132,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -185,7 +185,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } error = t; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferTimeout.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferTimeout.java index 7dc2c2146f..327a83b52a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferTimeout.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferTimeout.java @@ -289,7 +289,7 @@ void evict(@Nullable T evicted) { evicted, ex); } - Operators.onErrorDropped(ex); + Operators.onErrorDropped(ex, actual.currentContext()); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureDrop.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureDrop.java index e3db649aca..0947f957bd 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureDrop.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureDrop.java @@ -110,7 +110,7 @@ public void onNext(T t) { onDrop.accept(t); } catch (Throwable e) { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } return; } @@ -136,7 +136,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPeek.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPeek.java index 0e810fb858..fa0d3e6347 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPeek.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPeek.java @@ -166,7 +166,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -187,7 +187,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -219,7 +219,7 @@ public void onError(Throwable t) { afterTerminateHook.run(); } catch (Throwable e) { - afterErrorWithFailure(parent, e, t); + afterErrorWithFailure(parent, e, t, actual.currentContext()); } } } @@ -249,7 +249,7 @@ public void onComplete() { afterTerminateHook.run(); } catch (Throwable e) { - afterCompleteWithFailure(parent, e); + afterCompleteWithFailure(parent, e, actual.currentContext()); } } } @@ -309,20 +309,21 @@ public Runnable onCancelCall() { *

    *
  • The callback failure is thrown immediately if fatal.
  • *
  • {@link Operators#onOperatorError(Throwable)} is called
  • - *
  • {@link Operators#onErrorDropped(Throwable)} is called
  • + *
  • {@link Operators#onErrorDropped(Throwable, Context)} is called
  • *
*

* * @param parent the {@link SignalPeek} from which to get the callbacks * @param callbackFailure the afterTerminate callback failure + * @param context subscriber context */ //see https://github.com/reactor/reactor-core/issues/270 static void afterCompleteWithFailure(SignalPeek parent, - Throwable callbackFailure) { + Throwable callbackFailure, Context context) { Exceptions.throwIfFatal(callbackFailure); Throwable _e = Operators.onOperatorError(callbackFailure); - Operators.onErrorDropped(_e); + Operators.onErrorDropped(_e, context); } /** @@ -332,20 +333,21 @@ static void afterCompleteWithFailure(SignalPeek parent, *

  • The callback failure is thrown immediately if fatal.
  • *
  • {@link Operators#onOperatorError(Subscription, Throwable, Object)} is * called, adding the original error as suppressed
  • - *
  • {@link Operators#onErrorDropped(Throwable)} is called
  • + *
  • {@link Operators#onErrorDropped(Throwable, Context)} is called
  • * *

    * * @param parent the {@link SignalPeek} from which to get the callbacks * @param callbackFailure the afterTerminate callback failure * @param originalError the onError throwable + * @param context subscriber context */ //see https://github.com/reactor/reactor-core/issues/270 static void afterErrorWithFailure(SignalPeek parent, - Throwable callbackFailure, Throwable originalError) { + Throwable callbackFailure, Throwable originalError, Context context) { Exceptions.throwIfFatal(callbackFailure); Throwable _e = Operators.onOperatorError(null, callbackFailure, originalError); - Operators.onErrorDropped(_e); + Operators.onErrorDropped(_e, context); } } \ No newline at end of file diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPeekFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPeekFuseable.java index 9c2899a120..a48ca49fa2 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPeekFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPeekFuseable.java @@ -179,7 +179,7 @@ public void onNext(T t) { } else { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -200,7 +200,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -232,7 +232,7 @@ public void onError(Throwable t) { afterTerminateHook.run(); } catch (Throwable e) { - FluxPeek.afterErrorWithFailure(parent, e, t); + FluxPeek.afterErrorWithFailure(parent, e, t, actual.currentContext()); } } } @@ -268,7 +268,7 @@ public void onComplete() { afterTerminateHook.run(); } catch (Throwable e) { - FluxPeek.afterCompleteWithFailure(parent, e); + FluxPeek.afterCompleteWithFailure(parent, e, actual.currentContext()); } } } @@ -445,7 +445,7 @@ public void onNext(T t) { } else { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -466,7 +466,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return false; } @@ -486,7 +486,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -518,7 +518,7 @@ public void onError(Throwable t) { afterTerminateHook.run(); } catch (Throwable e) { - FluxPeek.afterErrorWithFailure(parent, e, t); + FluxPeek.afterErrorWithFailure(parent, e, t, actual.currentContext()); } } } @@ -553,7 +553,7 @@ public void onComplete() { afterTerminateHook.run(); } catch (Throwable e) { - FluxPeek.afterCompleteWithFailure(parent, e); + FluxPeek.afterCompleteWithFailure(parent, e, actual.currentContext()); } } } @@ -763,7 +763,7 @@ public Object scanUnsafe(Attr key) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -783,7 +783,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return false; } @@ -803,7 +803,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -835,7 +835,7 @@ public void onError(Throwable t) { afterTerminateHook.run(); } catch (Throwable e) { - FluxPeek.afterErrorWithFailure(parent, e, t); + FluxPeek.afterErrorWithFailure(parent, e, t, actual.currentContext()); } } } @@ -865,7 +865,7 @@ public void onComplete() { afterTerminateHook.run(); } catch (Throwable e) { - FluxPeek.afterCompleteWithFailure(parent, e); + FluxPeek.afterCompleteWithFailure(parent, e, actual.currentContext()); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPublishMulticast.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPublishMulticast.java index 692dfde1e1..f92fac915f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPublishMulticast.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPublishMulticast.java @@ -248,7 +248,7 @@ else if (m == Fuseable.ASYNC) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, context); return; } @@ -266,7 +266,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, context); return; } error = t; @@ -726,7 +726,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if(!parent.terminate()){ - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } actual.onError(t); @@ -825,7 +825,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if(!parent.terminate()){ - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } actual.onError(t); diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPublishOn.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPublishOn.java index cc4048cba7..e1d8675159 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPublishOn.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPublishOn.java @@ -220,7 +220,7 @@ public void onNext(T t) { } if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } if (!queue.offer(t)) { @@ -235,7 +235,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } error = t; @@ -699,7 +699,7 @@ public void onNext(T t) { } if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } if (!queue.offer(t)) { @@ -712,7 +712,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if(done){ - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } error = t; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSampleFirst.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSampleFirst.java index 77f323228f..ef6fa5df55 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSampleFirst.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSampleFirst.java @@ -204,7 +204,7 @@ void error(Throwable e) { } } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSampleTimeout.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSampleTimeout.java index 63ecdd5a1e..02365f6f5e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSampleTimeout.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSampleTimeout.java @@ -208,7 +208,7 @@ void error(Throwable t) { drain(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } } @@ -243,7 +243,7 @@ void otherError(long idx, Throwable e) { error(e); } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } @@ -386,7 +386,7 @@ public void onError(Throwable t) { main.otherError(index, t); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, main.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxScan.java b/reactor-core/src/main/java/reactor/core/publisher/FluxScan.java index b7ad830c6c..0fa5309a20 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxScan.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxScan.java @@ -84,7 +84,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -107,7 +107,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxScanSeed.java b/reactor-core/src/main/java/reactor/core/publisher/FluxScanSeed.java index 34ac2de4a8..318095e97a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxScanSeed.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxScanSeed.java @@ -189,7 +189,7 @@ public void onComplete() { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -199,7 +199,7 @@ public void onError(Throwable t) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntil.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntil.java index 50defa14df..0de0b932e7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntil.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntil.java @@ -72,7 +72,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -101,7 +101,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return true; } @@ -132,7 +132,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntilOther.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntilOther.java index f663d3c33b..f2618b4da5 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntilOther.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipUntilOther.java @@ -101,7 +101,7 @@ public void onNext(U t) { public void onError(Throwable t) { SkipUntilMainSubscriber m = main; if (m.gate) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, main.currentContext()); return; } m.onError(t); @@ -217,7 +217,7 @@ public void onError(Throwable t) { return; } else if (main == Operators.cancelledSubscription()){ - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } cancel(); diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipWhile.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipWhile.java index 3763f14f93..2e77f55a79 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSkipWhile.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSkipWhile.java @@ -72,7 +72,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -102,7 +102,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return true; } @@ -133,7 +133,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSwitchMap.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSwitchMap.java index 44e02658d5..0416ee41f7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSwitchMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSwitchMap.java @@ -196,7 +196,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -231,7 +231,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } @@ -246,7 +246,7 @@ public void onError(Throwable t) { drain(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } } @@ -415,7 +415,7 @@ void innerError(SwitchMapInner inner, Throwable e) { drain(); } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxTake.java b/reactor-core/src/main/java/reactor/core/publisher/FluxTake.java index 1af1a72281..a4e4038232 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxTake.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxTake.java @@ -100,7 +100,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -127,7 +127,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -217,7 +217,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -244,7 +244,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return true; } @@ -272,7 +272,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -372,7 +372,7 @@ public void onNext(T t) { return; } if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -399,7 +399,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntil.java b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntil.java index c2922926de..2006ed1ea7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntil.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntil.java @@ -70,7 +70,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -96,7 +96,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeWhile.java b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeWhile.java index 096861a21a..c9f1b3b088 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeWhile.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeWhile.java @@ -69,7 +69,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -97,7 +97,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxTimeout.java b/reactor-core/src/main/java/reactor/core/publisher/FluxTimeout.java index 374fedd1ca..11526492ee 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxTimeout.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxTimeout.java @@ -133,12 +133,12 @@ public void onNext(T t) { long idx = index; if (idx == Long.MIN_VALUE) { s.cancel(); - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } if (!INDEX.compareAndSet(this, idx, idx + 1)) { s.cancel(); - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -170,11 +170,11 @@ public void onNext(T t) { public void onError(Throwable t) { long idx = index; if (idx == Long.MIN_VALUE) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } if (!INDEX.compareAndSet(this, idx, Long.MIN_VALUE)) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxUsing.java b/reactor-core/src/main/java/reactor/core/publisher/FluxUsing.java index 7626593a70..8d82155fc2 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxUsing.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxUsing.java @@ -177,7 +177,7 @@ void cleanup() { resourceCleanup.accept(resource); } catch (Throwable e) { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } @@ -329,7 +329,7 @@ void cleanup() { resourceCleanup.accept(resource); } catch (Throwable e) { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } @@ -489,7 +489,7 @@ void cleanup() { resourceCleanup.accept(resource); } catch (Throwable e) { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWindow.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWindow.java index dd3baf55af..3884cbefa8 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWindow.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWindow.java @@ -148,7 +148,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -181,7 +181,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -315,7 +315,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -355,7 +355,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -517,7 +517,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -566,7 +566,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowBoundary.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowBoundary.java index 996af5ae4a..ff2639a135 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowBoundary.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowBoundary.java @@ -172,7 +172,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } synchronized (this) { @@ -184,7 +184,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -255,7 +255,7 @@ void boundaryError(Throwable e) { if (Exceptions.addThrowable(ERROR, this, e)) { drain(); } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowPredicate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowPredicate.java index c1fdb10c96..98bb884940 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowPredicate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowPredicate.java @@ -212,7 +212,7 @@ void offerNewWindow(@Nullable T emitInNewWindow) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } WindowFlux g = window; @@ -253,7 +253,7 @@ public void onError(Throwable t) { drain(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowWhen.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowWhen.java index 74ec1bdd46..242c2573cc 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowWhen.java @@ -195,7 +195,7 @@ public void onError(Throwable t) { drain(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); } } @@ -237,7 +237,7 @@ void starterError(Throwable e) { drain(); } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } @@ -262,7 +262,7 @@ void endError(Throwable e) { drain(); } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxZip.java b/reactor-core/src/main/java/reactor/core/publisher/FluxZip.java index 1f1e367ca9..0bbcc55319 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxZip.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxZip.java @@ -393,7 +393,7 @@ void error(Throwable e, int index) { actual.onError(e); } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } @@ -482,7 +482,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, parent.currentContext()); return; } done = true; @@ -493,7 +493,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, parent.currentContext()); return; } done = true; @@ -612,7 +612,7 @@ void error(Throwable e, int index) { drain(); } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } @@ -888,7 +888,7 @@ public Context currentContext() { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, parent.actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxZipIterable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxZipIterable.java index 8952ba53f2..0997a37dfb 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxZipIterable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxZipIterable.java @@ -119,7 +119,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -169,7 +169,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoAll.java b/reactor-core/src/main/java/reactor/core/publisher/MonoAll.java index 415d68c4dd..afe63f8e51 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoAll.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoAll.java @@ -112,7 +112,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoAny.java b/reactor-core/src/main/java/reactor/core/publisher/MonoAny.java index 5f437adae4..5f4b52f4b1 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoAny.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoAny.java @@ -113,7 +113,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCacheTime.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCacheTime.java index a4ef3ab7e3..4353025cf1 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCacheTime.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCacheTime.java @@ -114,7 +114,7 @@ static final class CoordinatorSubscriber implements InnerConsumer, Signal< static final AtomicReferenceFieldUpdater SUBSCRIBERS = AtomicReferenceFieldUpdater.newUpdater(CoordinatorSubscriber.class, Operators.MonoSubscriber[].class, "subscribers"); - public CoordinatorSubscriber(MonoCacheTime main) { + CoordinatorSubscriber(MonoCacheTime main) { this.main = main; //noinspection unchecked this.subscribers = EMPTY; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCollect.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCollect.java index e2b718a0da..3a5b2ede5a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCollect.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCollect.java @@ -111,7 +111,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -126,7 +126,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCreate.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCreate.java index bacf7831f3..60f690f7b8 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCreate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCreate.java @@ -163,7 +163,7 @@ public void error(Throwable e) { } } else { - Operators.onErrorDropped(e); + Operators.onErrorDropped(e, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoDelayElement.java b/reactor-core/src/main/java/reactor/core/publisher/MonoDelayElement.java index 1a606efe1d..9e8a491c6e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoDelayElement.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoDelayElement.java @@ -107,7 +107,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } this.done = true; @@ -131,7 +131,7 @@ public void onComplete() { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } this.done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoDoFinally.java b/reactor-core/src/main/java/reactor/core/publisher/MonoDoFinally.java index 7a07263f14..2f65aae8f6 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoDoFinally.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoDoFinally.java @@ -28,7 +28,7 @@ * {@link SignalType#CANCEL}). *

    * Note that any exception thrown by the hook are caught and bubbled up - * using {@link Operators#onErrorDropped(Throwable)}. + * using {@link Operators#onErrorDropped(Throwable, reactor.util.context.Context)}. * * @param the value type * @author Simon Baslé diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoDoFinallyFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/MonoDoFinallyFuseable.java index eee57d3b92..afa54d9adb 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoDoFinallyFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoDoFinallyFuseable.java @@ -29,7 +29,7 @@ * {@link SignalType#CANCEL}). *

    * Note that any exception thrown by the hook are caught and bubbled up - * using {@link Operators#onErrorDropped(Throwable)}. + * using {@link Operators#onErrorDropped(Throwable, reactor.util.context.Context)}. * * @param the value type * @author Simon Baslé diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoElementAt.java b/reactor-core/src/main/java/reactor/core/publisher/MonoElementAt.java index 339611f5f1..770229c6a3 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoElementAt.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoElementAt.java @@ -111,7 +111,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -130,7 +130,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoFilterWhen.java b/reactor-core/src/main/java/reactor/core/publisher/MonoFilterWhen.java index df5ce92dc1..db415cefa5 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoFilterWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoFilterWhen.java @@ -262,7 +262,7 @@ public void onError(Throwable t) { done = true; main.innerError(t); } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, main.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMap.java b/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMap.java index b23db67fa6..71df80a41f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMap.java @@ -107,7 +107,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } done = true; @@ -155,7 +155,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -231,7 +231,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(R t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, parent.currentContext()); return; } done = true; @@ -241,7 +241,7 @@ public void onNext(R t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, parent.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMapMany.java b/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMapMany.java index 8e7198f0e7..e395a339c9 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMapMany.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMapMany.java @@ -185,7 +185,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (hasValue) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } actual.onError(t); diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreThen.java b/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreThen.java index c2dcc65aac..cc66bdd532 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreThen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreThen.java @@ -281,7 +281,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, parent.currentContext()); return; } done = true; @@ -291,7 +291,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, parent.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoNext.java b/reactor-core/src/main/java/reactor/core/publisher/MonoNext.java index acb23f9ecf..029cffc5d1 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoNext.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoNext.java @@ -68,7 +68,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -80,7 +80,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoPeekTerminal.java b/reactor-core/src/main/java/reactor/core/publisher/MonoPeekTerminal.java index ec258ed8cf..5903478d55 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoPeekTerminal.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoPeekTerminal.java @@ -154,7 +154,7 @@ public void onNext(T t) { } else { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } //implementation note: this operator doesn't expect the source to be anything but a Mono @@ -188,7 +188,8 @@ public void onNext(T t) { } catch (Throwable e) { //don't invoke error callback, see https://github.com/reactor/reactor-core/issues/270 - Operators.onErrorDropped(Operators.onOperatorError(s, e, t)); + Operators.onErrorDropped(Operators.onOperatorError(s, e, t), + actual.currentContext()); } } } @@ -197,7 +198,7 @@ public void onNext(T t) { @Override public boolean tryOnNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return false; } if (actualConditional == null) { @@ -236,7 +237,8 @@ public boolean tryOnNext(T t) { } catch (Throwable e) { //don't invoke error callback, see https://github.com/reactor/reactor-core/issues/270 - Operators.onErrorDropped(Operators.onOperatorError(s, e, t)); + Operators.onErrorDropped(Operators.onOperatorError(s, e, t), + actual.currentContext()); } } @@ -246,7 +248,7 @@ public boolean tryOnNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; @@ -275,7 +277,8 @@ public void onError(Throwable t) { } catch (Throwable e) { //don't invoke error callback, see https://github.com/reactor/reactor-core/issues/270 - Operators.onErrorDropped(Operators.onOperatorError(e)); + Operators.onErrorDropped(Operators.onOperatorError(e), + actual.currentContext()); } } } @@ -315,7 +318,8 @@ public void onComplete() { } catch (Throwable e) { //don't invoke error callback, see https://github.com/reactor/reactor-core/issues/270 - Operators.onErrorDropped(Operators.onOperatorError(e)); + Operators.onErrorDropped(Operators.onOperatorError(e), + actual.currentContext()); } } } @@ -353,7 +357,8 @@ public T poll() { parent.onAfterTerminateCall.accept(v, null); } catch (Throwable t) { - Operators.onErrorDropped(Operators.onOperatorError(t)); + Operators.onErrorDropped(Operators.onOperatorError(t), + actual.currentContext()); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoReduce.java b/reactor-core/src/main/java/reactor/core/publisher/MonoReduce.java index e15522e0b0..7f9ea9f369 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoReduce.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoReduce.java @@ -83,7 +83,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } T r = result; @@ -109,7 +109,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoReduceSeed.java b/reactor-core/src/main/java/reactor/core/publisher/MonoReduceSeed.java index 3d0076dfb7..88a5d9a17e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoReduceSeed.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoReduceSeed.java @@ -132,7 +132,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSingle.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSingle.java index cb93acbf14..d3c0d16554 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSingle.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSingle.java @@ -117,7 +117,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } value = t; @@ -132,7 +132,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoStreamCollector.java b/reactor-core/src/main/java/reactor/core/publisher/MonoStreamCollector.java index eddfa4b231..85b1a14bc5 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoStreamCollector.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoStreamCollector.java @@ -118,7 +118,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } try { @@ -132,7 +132,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoToCompletableFuture.java b/reactor-core/src/main/java/reactor/core/publisher/MonoToCompletableFuture.java index fcb47e3ed7..21bad8915a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoToCompletableFuture.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoToCompletableFuture.java @@ -18,7 +18,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicReference; -import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; diff --git a/reactor-core/src/main/java/reactor/core/publisher/Operators.java b/reactor-core/src/main/java/reactor/core/publisher/Operators.java index 1e9f95f862..5d4c9101be 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/Operators.java +++ b/reactor-core/src/main/java/reactor/core/publisher/Operators.java @@ -30,12 +30,12 @@ import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; -import reactor.core.Disposables; import reactor.core.Exceptions; import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.util.Logger; import reactor.util.Loggers; +import reactor.util.context.Context; /** * An helper to support "Operator" writing, handle noop subscriptions, validate request @@ -268,26 +268,22 @@ public static long multiplyCap(long a, long b) { } /** - * An unexpected exception is about to be dropped, and it additionally - * masks another one due to callback failure. The later will be suppressed by - * the dropped exception. + * An unexpected exception is about to be dropped. * - * @param e the exception to handle - * @param root the optional root cause to suppress + * @param e the dropped exception + * @see #onErrorDropped(Throwable, Context) */ - public static void onErrorDropped(Throwable e, @Nullable Throwable root) { - if(root != null && root != e) { - e.addSuppressed(root); - } - onErrorDropped(e); + public static void onErrorDropped(Throwable e) { + onErrorDropped(e, Context.empty()); } /** * An unexpected exception is about to be dropped. * * @param e the dropped exception + * @param context a context that might hold a local error consumer */ - public static void onErrorDropped(Throwable e) { + public static void onErrorDropped(Throwable e, Context context) { Consumer hook = Hooks.onErrorDroppedHook; if (hook == null) { throw Exceptions.bubble(e); @@ -303,18 +299,31 @@ public static void onErrorDropped(Throwable e) { * * @param the dropped value type * @param t the dropped data - * @see #onNextDropped(Object) + * @see #onNextDropped(Object, Context) */ public static void onNextDropped(T t) { - //noinspection ConstantConditions - if(t != null) { - Consumer hook = Hooks.onNextDroppedHook; - if (hook != null) { - hook.accept(t); - } - else if (log.isDebugEnabled()) { - log.debug("onNextDropped: " + t); - } + onNextDropped(t, Context.empty()); + } + + /** + * An unexpected event is about to be dropped. + *

    + * If no hook is registered for {@link Hooks#onNextDropped(Consumer)}, the dropped + * element is just logged at DEBUG level. + * + * @param the dropped value type + * @param t the dropped data + * @param context a context that might hold a local error consumer + */ + public static void onNextDropped(T t, Context context) { + Objects.requireNonNull(t, "onNext"); + Objects.requireNonNull(context, "context"); + Consumer hook = Hooks.onNextDroppedHook; + if (hook != null) { + hook.accept(t); + } + else if (log.isDebugEnabled()) { + log.debug("onNextDropped: " + t); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelCollect.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelCollect.java index bf9f5d62f0..7b5afd9f08 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelCollect.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelCollect.java @@ -137,7 +137,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -152,7 +152,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeReduce.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeReduce.java index 2eb7f5f035..4fa03fe6d2 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeReduce.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeReduce.java @@ -160,7 +160,7 @@ void innerError(Throwable ex) { actual.onError(ex); } else if(error != ex) { - Operators.onErrorDropped(ex); + Operators.onErrorDropped(ex, actual.currentContext()); } } @@ -252,7 +252,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, parent.currentContext()); return; } T v = value; @@ -277,7 +277,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, parent.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSequential.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSequential.java index 3467b1fe90..0c1bb5959a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSequential.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSequential.java @@ -208,7 +208,7 @@ void onError(Throwable ex) { drain(); } else if(error != ex) { - Operators.onErrorDropped(ex); + Operators.onErrorDropped(ex, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSort.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSort.java index 1203617d91..77f9202c2e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSort.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSort.java @@ -191,7 +191,7 @@ void innerError(Throwable ex) { drain(); } else if(error != ex) { - Operators.onErrorDropped(ex); + Operators.onErrorDropped(ex, actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelReduceSeed.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelReduceSeed.java index fdcc5d3681..316aac576c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelReduceSeed.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelReduceSeed.java @@ -137,7 +137,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -157,7 +157,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelSource.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelSource.java index 67a59d0d66..b4624b216d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelSource.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelSource.java @@ -221,7 +221,7 @@ void setupSubscribers() { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, currentContext()); return; } if (sourceMode == Fuseable.NONE) { @@ -236,7 +236,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, currentContext()); return; } error = t; diff --git a/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java index 7dfb627b37..94f1debcd5 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java @@ -27,7 +27,6 @@ import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; -import reactor.core.Exceptions; import reactor.core.Fuseable; import reactor.core.Scannable; import reactor.core.scheduler.Scheduler; diff --git a/reactor-core/src/main/java/reactor/core/publisher/UnicastProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/UnicastProcessor.java index f349a1f59f..5dae84de63 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/UnicastProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/UnicastProcessor.java @@ -307,7 +307,7 @@ public int getPrefetch() { @Override public void onNext(T t) { if (done || cancelled) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, actual.currentContext()); return; } @@ -332,7 +332,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done || cancelled) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, actual.currentContext()); return; } From 9831c5a59d38b174c58539fc40b08961b98b0348 Mon Sep 17 00:00:00 2001 From: Stephane Maldini Date: Wed, 30 Aug 2017 18:41:41 -0700 Subject: [PATCH 2/5] Contextualize Operators.onOperatorError and onRejectedExecution - fix UnicastProcessor currentContext --- .../core/publisher/BaseSubscriber.java | 8 +-- .../core/publisher/BlockingIterable.java | 3 +- .../core/publisher/DirectProcessor.java | 4 +- .../core/publisher/EmitterProcessor.java | 10 ++- .../core/publisher/EventLoopProcessor.java | 7 +-- .../java/reactor/core/publisher/Flux.java | 2 +- .../reactor/core/publisher/FluxBuffer.java | 6 +- .../core/publisher/FluxBufferBoundary.java | 6 +- .../core/publisher/FluxBufferPredicate.java | 6 +- .../core/publisher/FluxBufferTimeOrSize.java | 3 +- .../core/publisher/FluxBufferWhen.java | 4 +- .../reactor/core/publisher/FluxCallable.java | 2 +- .../reactor/core/publisher/FluxCancelOn.java | 2 +- .../core/publisher/FluxCombineLatest.java | 15 +++-- .../core/publisher/FluxConcatIterable.java | 8 ++- .../reactor/core/publisher/FluxConcatMap.java | 24 ++++--- .../core/publisher/FluxContextStart.java | 2 +- .../reactor/core/publisher/FluxCreate.java | 2 +- .../reactor/core/publisher/FluxDefer.java | 2 +- .../reactor/core/publisher/FluxDistinct.java | 18 +++--- .../core/publisher/FluxDistinctFuseable.java | 2 +- .../publisher/FluxDistinctUntilChanged.java | 8 +-- .../reactor/core/publisher/FluxDoOnEach.java | 6 +- .../reactor/core/publisher/FluxError.java | 6 +- .../reactor/core/publisher/FluxFilter.java | 8 +-- .../core/publisher/FluxFilterFuseable.java | 8 +-- .../core/publisher/FluxFirstEmitting.java | 9 ++- .../reactor/core/publisher/FluxFlatMap.java | 15 ++--- .../core/publisher/FluxFlattenIterable.java | 27 +++++--- .../reactor/core/publisher/FluxGenerate.java | 4 +- .../reactor/core/publisher/FluxGroupBy.java | 5 +- .../reactor/core/publisher/FluxGroupJoin.java | 12 ++-- .../reactor/core/publisher/FluxHandle.java | 20 +++--- .../core/publisher/FluxHandleFuseable.java | 28 +++++---- .../reactor/core/publisher/FluxInterval.java | 3 +- .../reactor/core/publisher/FluxIterable.java | 4 +- .../java/reactor/core/publisher/FluxJoin.java | 17 +++-- .../java/reactor/core/publisher/FluxMap.java | 6 +- .../core/publisher/FluxMapFuseable.java | 6 +- .../reactor/core/publisher/FluxMapSignal.java | 6 +- .../core/publisher/FluxMergeSequential.java | 10 +-- .../publisher/FluxOnBackpressureBuffer.java | 3 +- .../FluxOnBackpressureBufferStrategy.java | 6 +- .../FluxOnBackpressureBufferTimeout.java | 3 +- .../publisher/FluxOnBackpressureDrop.java | 2 +- .../core/publisher/FluxOnErrorResume.java | 2 +- .../java/reactor/core/publisher/FluxPeek.java | 21 ++++--- .../core/publisher/FluxPeekFuseable.java | 63 +++++++++++-------- .../reactor/core/publisher/FluxPublish.java | 9 ++- .../core/publisher/FluxPublishMulticast.java | 8 +-- .../reactor/core/publisher/FluxPublishOn.java | 23 ++++--- .../core/publisher/FluxRepeatPredicate.java | 2 +- .../core/publisher/FluxRepeatWhen.java | 2 +- .../reactor/core/publisher/FluxReplay.java | 4 +- .../core/publisher/FluxRetryPredicate.java | 2 +- .../reactor/core/publisher/FluxRetryWhen.java | 2 +- .../core/publisher/FluxSampleFirst.java | 2 +- .../core/publisher/FluxSampleTimeout.java | 2 +- .../java/reactor/core/publisher/FluxScan.java | 2 +- .../reactor/core/publisher/FluxScanSeed.java | 4 +- .../reactor/core/publisher/FluxSkipUntil.java | 4 +- .../reactor/core/publisher/FluxSkipWhile.java | 4 +- .../reactor/core/publisher/FluxStream.java | 2 +- .../core/publisher/FluxSubscribeOn.java | 8 ++- .../publisher/FluxSubscribeOnCallable.java | 8 ++- .../core/publisher/FluxSubscribeOnValue.java | 5 +- .../reactor/core/publisher/FluxSwitchMap.java | 2 +- .../reactor/core/publisher/FluxTakeUntil.java | 2 +- .../reactor/core/publisher/FluxTakeWhile.java | 2 +- .../reactor/core/publisher/FluxTimeout.java | 3 +- .../reactor/core/publisher/FluxUsing.java | 18 +++--- .../core/publisher/FluxWindowPredicate.java | 8 ++- .../core/publisher/FluxWindowTimeOrSize.java | 5 +- .../core/publisher/FluxWindowWhen.java | 2 +- .../core/publisher/FluxWithLatestFrom.java | 2 +- .../java/reactor/core/publisher/FluxZip.java | 28 ++++++--- .../core/publisher/FluxZipIterable.java | 10 +-- .../core/publisher/LambdaMonoSubscriber.java | 2 +- .../java/reactor/core/publisher/Mono.java | 2 +- .../java/reactor/core/publisher/MonoAll.java | 2 +- .../java/reactor/core/publisher/MonoAny.java | 2 +- .../reactor/core/publisher/MonoCallable.java | 2 +- .../reactor/core/publisher/MonoCollect.java | 4 +- .../core/publisher/MonoCollectList.java | 2 +- .../reactor/core/publisher/MonoCreate.java | 2 +- .../reactor/core/publisher/MonoDefer.java | 2 +- .../reactor/core/publisher/MonoDelay.java | 5 +- .../core/publisher/MonoDelayElement.java | 3 +- .../reactor/core/publisher/MonoElementAt.java | 2 +- .../reactor/core/publisher/MonoError.java | 2 +- .../reactor/core/publisher/MonoFirst.java | 12 ++-- .../reactor/core/publisher/MonoFlatMap.java | 9 ++- .../core/publisher/MonoFlatMapMany.java | 6 +- .../core/publisher/MonoFlattenIterable.java | 6 +- .../core/publisher/MonoIgnoreThen.java | 6 +- .../core/publisher/MonoPeekTerminal.java | 37 ++++++----- .../core/publisher/MonoPublishMulticast.java | 2 +- .../reactor/core/publisher/MonoPublishOn.java | 2 +- .../reactor/core/publisher/MonoReduce.java | 3 +- .../core/publisher/MonoReduceSeed.java | 4 +- .../core/publisher/MonoRepeatWhen.java | 2 +- .../reactor/core/publisher/MonoRunnable.java | 2 +- .../core/publisher/MonoSequenceEqual.java | 6 +- .../reactor/core/publisher/MonoSingle.java | 3 +- .../core/publisher/MonoStreamCollector.java | 6 +- .../core/publisher/MonoSubscribeOn.java | 6 +- .../publisher/MonoSubscribeOnCallable.java | 3 +- .../core/publisher/MonoSubscribeOnValue.java | 3 +- .../core/publisher/MonoSubscriberContext.java | 2 +- .../reactor/core/publisher/MonoSupplier.java | 2 +- .../core/publisher/MonoTakeLastOne.java | 3 +- .../publisher/MonoToCompletableFuture.java | 2 +- .../reactor/core/publisher/MonoUsing.java | 6 +- .../java/reactor/core/publisher/MonoZip.java | 3 +- .../reactor/core/publisher/Operators.java | 38 +++++++---- .../core/publisher/ParallelCollect.java | 5 +- .../core/publisher/ParallelMergeReduce.java | 7 ++- .../publisher/ParallelMergeSequential.java | 6 +- .../core/publisher/ParallelReduceSeed.java | 5 +- .../core/publisher/ParallelSource.java | 24 ++----- .../core/publisher/ReplayProcessor.java | 2 +- .../core/publisher/UnicastProcessor.java | 15 +++-- .../reactor/core/publisher/HooksTest.java | 7 ++- .../test/StepVerifierAssertionsTests.java | 15 ++--- 124 files changed, 519 insertions(+), 392 deletions(-) diff --git a/reactor-core/src/main/java/reactor/core/publisher/BaseSubscriber.java b/reactor-core/src/main/java/reactor/core/publisher/BaseSubscriber.java index 2b326d2514..fbe99e189b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/BaseSubscriber.java +++ b/reactor-core/src/main/java/reactor/core/publisher/BaseSubscriber.java @@ -146,7 +146,7 @@ public final void onSubscribe(Subscription s) { hookOnSubscribe(s); } catch (Throwable throwable) { - onError(Operators.onOperatorError(s, throwable)); + onError(Operators.onOperatorError(s, throwable, currentContext())); } } } @@ -158,7 +158,7 @@ public final void onNext(T value) { hookOnNext(value); } catch (Throwable throwable) { - onError(Operators.onOperatorError(subscription, throwable, value)); + onError(Operators.onOperatorError(subscription, throwable, value, currentContext())); } } @@ -198,7 +198,7 @@ public final void onComplete() { } catch (Throwable throwable) { //onError itself will short-circuit due to the CancelledSubscription being push above - hookOnError(Operators.onOperatorError(throwable)); + hookOnError(Operators.onOperatorError(throwable, currentContext())); } finally { safeHookFinally(SignalType.ON_COMPLETE); @@ -230,7 +230,7 @@ public final void cancel() { hookOnCancel(); } catch (Throwable throwable) { - hookOnError(Operators.onOperatorError(subscription, throwable)); + hookOnError(Operators.onOperatorError(subscription, throwable, currentContext())); } finally { safeHookFinally(SignalType.CANCEL); diff --git a/reactor-core/src/main/java/reactor/core/publisher/BlockingIterable.java b/reactor-core/src/main/java/reactor/core/publisher/BlockingIterable.java index c13a6c9662..8d27831024 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/BlockingIterable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/BlockingIterable.java @@ -35,6 +35,7 @@ import org.reactivestreams.Subscription; import reactor.core.Exceptions; import reactor.core.Scannable; +import reactor.util.context.Context; /** * An iterable that consumes a Publisher in a blocking fashion. @@ -221,7 +222,7 @@ public void onNext(T t) { onError(Operators.onOperatorError(null, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), - t)); + t, currentContext())); } else { signalConsumer(); diff --git a/reactor-core/src/main/java/reactor/core/publisher/DirectProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/DirectProcessor.java index e3a4a79311..1fc8491287 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/DirectProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/DirectProcessor.java @@ -98,7 +98,7 @@ public void onNext(T t) { DirectInner[] inners = subscribers; if (inners == TERMINATED) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, currentContext()); return; } @@ -114,7 +114,7 @@ public void onError(Throwable t) { DirectInner[] inners = subscribers; if (inners == TERMINATED) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, currentContext()); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java index 2aa67dbb6f..c190be1b34 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java @@ -228,7 +228,7 @@ else if (m == Fuseable.ASYNC) { @SuppressWarnings("unchecked") public void onNext(T t) { if (done) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, currentContext()); return; } @@ -269,7 +269,7 @@ public void onNext(T t) { public void onError(Throwable t) { Objects.requireNonNull(t, "onError"); if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, currentContext()); return; } if (Exceptions.addThrowable(ERROR, this, t)) { @@ -374,8 +374,7 @@ final void drain() { } catch (Throwable ex) { Exceptions.addThrowable(ERROR, - this, - Operators.onOperatorError(s, ex)); + this, Operators.onOperatorError(s, ex, currentContext())); d = true; v = null; } @@ -399,8 +398,7 @@ final void drain() { } catch (Throwable ex) { Exceptions.addThrowable(ERROR, - this, - Operators.onOperatorError(s, ex)); + this, Operators.onOperatorError(s, ex, currentContext())); d = true; v = null; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/EventLoopProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/EventLoopProcessor.java index eec6eedb02..eb9a71a8e9 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/EventLoopProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/EventLoopProcessor.java @@ -31,7 +31,6 @@ import java.util.stream.Stream; import org.reactivestreams.Subscription; -import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.concurrent.Queues; import reactor.util.concurrent.WaitStrategy; @@ -427,7 +426,7 @@ final public void onSubscribe(final Subscription s) { } } catch (Throwable t) { - onError(Operators.onOperatorError(s, t)); + onError(Operators.onOperatorError(s, t, currentContext())); } } } @@ -448,7 +447,7 @@ public final void shutdown() { requestTaskExecutor.shutdown(); } catch (Throwable t) { - onError(Operators.onOperatorError(t)); + onError(Operators.onOperatorError(t, currentContext())); } } @@ -527,7 +526,7 @@ public void run() { } return; } - parent.onError(Operators.onOperatorError(t)); + parent.onError(Operators.onOperatorError(t, parent.currentContext())); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/Flux.java b/reactor-core/src/main/java/reactor/core/publisher/Flux.java index 5cf95da989..69c24356d4 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/Flux.java +++ b/reactor-core/src/main/java/reactor/core/publisher/Flux.java @@ -3535,7 +3535,7 @@ public final Flux doOnNext(Consumer onNext) { * receives any request. *

    * Note that non fatal error raised in the callback will not be propagated and - * will simply trigger {@link Operators#onOperatorError(Throwable)}. + * will simply trigger {@link Operators#onOperatorError(Throwable, Context)}. * *

    * diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBuffer.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBuffer.java index 4081b1100c..c0193745b5 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBuffer.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBuffer.java @@ -140,7 +140,7 @@ public void onNext(T t) { "The bufferSupplier returned a null buffer"); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } buffer = b; @@ -285,7 +285,7 @@ public void onNext(T t) { "The bufferSupplier returned a null buffer"); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -464,7 +464,7 @@ public void onNext(T t) { "The bufferSupplier returned a null buffer"); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferBoundary.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferBoundary.java index 7ddc48bb37..2b9114bd2f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferBoundary.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferBoundary.java @@ -68,7 +68,7 @@ public void subscribe(CoreSubscriber actual) { "The bufferSupplier returned a null buffer"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -253,7 +253,7 @@ void otherNext() { "The bufferSupplier returned a null buffer"); } catch (Throwable e) { - otherError(Operators.onOperatorError(other, e)); + otherError(Operators.onOperatorError(other, e, actual.currentContext())); return; } @@ -281,7 +281,7 @@ boolean emit(C b) { } else { actual.onError(Operators.onOperatorError(this, Exceptions - .failWithOverflow(), b)); + .failWithOverflow(), b, actual.currentContext())); return false; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferPredicate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferPredicate.java index 04919b1481..9e7d27b3d6 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferPredicate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferPredicate.java @@ -84,7 +84,7 @@ public void subscribe(CoreSubscriber actual) { "The bufferSupplier returned a null initial buffer"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -195,7 +195,7 @@ public boolean tryOnNext(T t) { match = predicate.test(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return true; } @@ -237,7 +237,7 @@ private C triggerNewBuffer() { "The bufferSupplier returned a null buffer"); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e)); + onError(Operators.onOperatorError(s, e, actual.currentContext())); return null; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferTimeOrSize.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferTimeOrSize.java index 42a07d5828..0d3d4efc1f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferTimeOrSize.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferTimeOrSize.java @@ -199,7 +199,8 @@ public void onNext(final T value) { timespanRegistration = timer.schedule(flushTask, timespan, TimeUnit.MILLISECONDS); } catch (RejectedExecutionException ree) { - onError(Operators.onRejectedExecution(ree, this, null, value)); + onError(Operators.onRejectedExecution(ree, this, null, value, + actual.currentContext())); return; } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferWhen.java b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferWhen.java index f788475d2f..ad84c26e3c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxBufferWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxBufferWhen.java @@ -328,7 +328,7 @@ void startNext(U u) { "The bufferSupplier returned a null buffer"); } catch (Throwable e) { - anyError(Operators.onOperatorError(starter, e, u)); + anyError(Operators.onOperatorError(starter, e, u, actual.currentContext())); return; } @@ -348,7 +348,7 @@ void startNext(U u) { "The end returned a null publisher"); } catch (Throwable e) { - anyError(Operators.onOperatorError(starter, e, u)); + anyError(Operators.onOperatorError(starter, e, u, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxCallable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxCallable.java index d7df06c745..1082725b3a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxCallable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxCallable.java @@ -45,7 +45,7 @@ public void subscribe(CoreSubscriber actual) { v = Objects.requireNonNull(callable.call(), "callable returned null"); } catch (Throwable ex) { - actual.onError(Operators.onOperatorError(ex)); + actual.onError(Operators.onOperatorError(ex, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxCancelOn.java b/reactor-core/src/main/java/reactor/core/publisher/FluxCancelOn.java index ccbb2cf93f..b5a9fbd7e3 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxCancelOn.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxCancelOn.java @@ -110,7 +110,7 @@ public void cancel() { scheduler.schedule(this); } catch (RejectedExecutionException ree) { - throw Operators.onRejectedExecution(ree); + throw Operators.onRejectedExecution(ree, actual.currentContext()); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxCombineLatest.java b/reactor-core/src/main/java/reactor/core/publisher/FluxCombineLatest.java index cea34ba70d..984aeaeab6 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxCombineLatest.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxCombineLatest.java @@ -106,7 +106,8 @@ public void subscribe(CoreSubscriber actual) { it = Objects.requireNonNull(iterable.iterator(), "The iterator returned is null"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, + actual.currentContext())); return; } @@ -118,7 +119,8 @@ public void subscribe(CoreSubscriber actual) { b = it.hasNext(); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, + actual.currentContext())); return; } @@ -133,7 +135,8 @@ public void subscribe(CoreSubscriber actual) { "The Publisher returned by the iterator is null"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, + actual.currentContext())); return; } @@ -307,7 +310,8 @@ void innerValue(int index, T value) { new SourceAndArray(subscribers[index], os.clone()); if (!queue.offer(sa)) { - innerError(Operators.onOperatorError(this, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL))); + innerError(Operators.onOperatorError(this, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), + actual.currentContext())); return; } @@ -432,7 +436,8 @@ void drainAsync() { w = Objects.requireNonNull(combiner.apply(v.array), "Combiner returned null"); } catch (Throwable ex) { - ex = Operators.onOperatorError(this, ex, v.array); + ex = Operators.onOperatorError(this, ex, v.array, + actual.currentContext()); Exceptions.addThrowable(ERROR, this, ex); //noinspection ConstantConditions ex = Exceptions.terminate(ERROR, this); diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxConcatIterable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxConcatIterable.java index 889117fdce..6e6cb9c81e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxConcatIterable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxConcatIterable.java @@ -48,7 +48,7 @@ public void subscribe(CoreSubscriber actual) { "The Iterator returned is null"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -102,7 +102,8 @@ public void onComplete() { b = a.hasNext(); } catch (Throwable e) { - onError(Operators.onOperatorError(this, e)); + onError(Operators.onOperatorError(this, e, + actual.currentContext())); return; } @@ -122,7 +123,8 @@ public void onComplete() { "The Publisher returned by the iterator is null"); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(this, e)); + actual.onError(Operators.onOperatorError(this, e, + actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxConcatMap.java b/reactor-core/src/main/java/reactor/core/publisher/FluxConcatMap.java index 9b78bc0dbb..4a7261711e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxConcatMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxConcatMap.java @@ -234,7 +234,8 @@ public void onNext(T t) { drain(); } else if (!queue.offer(t)) { - onError(Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t)); + onError(Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t, + actual.currentContext())); } else { drain(); @@ -337,7 +338,8 @@ void drain() { v = queue.poll(); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(s, e)); + actual.onError(Operators.onOperatorError(s, e, + actual.currentContext())); return; } @@ -356,7 +358,8 @@ void drain() { "The mapper returned a null Publisher"); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(s, e, v)); + actual.onError(Operators.onOperatorError(s, e, v, + actual.currentContext())); return; } @@ -381,7 +384,8 @@ void drain() { vr = callable.call(); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(s, e, v)); + actual.onError(Operators.onOperatorError(s, e, v, + actual.currentContext())); return; } @@ -570,7 +574,8 @@ public void onNext(T t) { drain(); } else if (!queue.offer(t)) { - onError(Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t)); + onError(Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t, + actual.currentContext())); } else { drain(); @@ -664,7 +669,8 @@ void drain() { v = queue.poll(); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(s, e)); + actual.onError(Operators.onOperatorError(s, e, + actual.currentContext())); return; } @@ -689,7 +695,8 @@ void drain() { "The mapper returned a null Publisher"); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(s, e, v)); + actual.onError(Operators.onOperatorError(s, e, v, + actual.currentContext())); return; } @@ -714,7 +721,8 @@ void drain() { vr = supplier.call(); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(s, e, v)); + actual.onError(Operators.onOperatorError(s, e, v, + actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxContextStart.java b/reactor-core/src/main/java/reactor/core/publisher/FluxContextStart.java index 1e2e2c39f8..d552278a14 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxContextStart.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxContextStart.java @@ -42,7 +42,7 @@ public void subscribe(CoreSubscriber actual) { c = doOnContext.apply(actual.currentContext()); } catch (Throwable t) { - Operators.error(actual, Operators.onOperatorError(t)); + Operators.error(actual, Operators.onOperatorError(t, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxCreate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxCreate.java index 7289fde37f..e14e4dd0d7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxCreate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxCreate.java @@ -95,7 +95,7 @@ public void subscribe(CoreSubscriber actual) { } catch (Throwable ex) { Exceptions.throwIfFatal(ex); - sink.error(Operators.onOperatorError(ex)); + sink.error(Operators.onOperatorError(ex, actual.currentContext())); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDefer.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDefer.java index 2199a88082..fb292cc637 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDefer.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDefer.java @@ -47,7 +47,7 @@ public void subscribe(CoreSubscriber actual) { "The Publisher returned by the supplier is null"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinct.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinct.java index 301231ee34..6062b62702 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinct.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinct.java @@ -64,7 +64,7 @@ public void subscribe(CoreSubscriber actual) { "The collectionSupplier returned a null collection"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -129,7 +129,7 @@ public boolean tryOnNext(T t) { "The distinct extractor returned a null value."); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return true; } @@ -139,7 +139,7 @@ public boolean tryOnNext(T t) { b = collection.add(k); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return true; } @@ -241,7 +241,7 @@ public void onNext(T t) { "The distinct extractor returned a null value."); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -251,7 +251,7 @@ public void onNext(T t) { b = collection.add(k); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -277,7 +277,7 @@ public boolean tryOnNext(T t) { "The distinct extractor returned a null value."); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return true; } @@ -287,7 +287,7 @@ public boolean tryOnNext(T t) { b = collection.add(k); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return true; } @@ -402,7 +402,7 @@ public boolean tryOnNext(T t) { "The distinct extractor returned a null value."); } catch (Throwable e) { - onError(Operators.onOperatorError(qs, e, t)); + onError(Operators.onOperatorError(qs, e, t, actual.currentContext())); return true; } @@ -412,7 +412,7 @@ public boolean tryOnNext(T t) { b = collection.add(k); } catch (Throwable e) { - onError(Operators.onOperatorError(qs, e, t)); + onError(Operators.onOperatorError(qs, e, t, actual.currentContext())); return true; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctFuseable.java index 56adcef57c..9ed8982b52 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctFuseable.java @@ -60,7 +60,7 @@ public void subscribe(CoreSubscriber actual) { "The collectionSupplier returned a null collection"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctUntilChanged.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctUntilChanged.java index 8fb75c10be..9be316b2de 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctUntilChanged.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDistinctUntilChanged.java @@ -107,7 +107,7 @@ public boolean tryOnNext(T t) { "The distinct extractor returned a null value."); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return true; } @@ -123,7 +123,7 @@ public boolean tryOnNext(T t) { equiv = keyComparator.test(lastKey, k); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return true; } @@ -233,7 +233,7 @@ public boolean tryOnNext(T t) { "The distinct extractor returned a null value."); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return true; } @@ -248,7 +248,7 @@ public boolean tryOnNext(T t) { equiv = keyComparator.test(lastKey, k); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return true; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxDoOnEach.java b/reactor-core/src/main/java/reactor/core/publisher/FluxDoOnEach.java index 5fb168133b..a7d82c28c1 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxDoOnEach.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxDoOnEach.java @@ -106,7 +106,7 @@ public void onNext(T t) { onSignal.accept(this); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -126,7 +126,7 @@ public void onError(Throwable t) { } catch (Throwable e) { //this performs a throwIfFatal or suppresses t in e - t = Operators.onOperatorError(null, e, t); + t = Operators.onOperatorError(null, e, t, actual.currentContext()); } try { @@ -152,7 +152,7 @@ public void onComplete() { } catch (Throwable e) { done = false; - onError(Operators.onOperatorError(s, e)); + onError(Operators.onOperatorError(s, e, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxError.java b/reactor-core/src/main/java/reactor/core/publisher/FluxError.java index 72277b657a..81cd756f38 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxError.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxError.java @@ -18,12 +18,8 @@ import java.util.Objects; -import org.reactivestreams.Subscriber; import reactor.core.Exceptions; import reactor.core.Fuseable; -import reactor.util.context.Context; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import javax.annotation.Nullable; import reactor.core.CoreSubscriber; @@ -44,7 +40,7 @@ final class FluxError extends Flux implements Fuseable.ScalarCallable { @Override public void subscribe(CoreSubscriber actual) { - Operators.error(actual, Operators.onOperatorError(error)); + Operators.error(actual, Operators.onOperatorError(error, actual.currentContext())); } @Override diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFilter.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFilter.java index 68bd62d503..a1eb150dd2 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFilter.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFilter.java @@ -90,7 +90,7 @@ public void onNext(T t) { b = predicate.test(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } if (b) { @@ -114,7 +114,7 @@ public boolean tryOnNext(T t) { b = predicate.test(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return false; } if (b) { @@ -206,7 +206,7 @@ public void onNext(T t) { b = predicate.test(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } if (b) { @@ -230,7 +230,7 @@ public boolean tryOnNext(T t) { b = predicate.test(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return false; } return b && actual.tryOnNext(t); diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFilterFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFilterFuseable.java index 67996d90b2..e4123c536f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFilterFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFilterFuseable.java @@ -97,7 +97,7 @@ public void onNext(T t) { b = predicate.test(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } if (b) { @@ -122,7 +122,7 @@ public boolean tryOnNext(T t) { b = predicate.test(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return false; } if (b) { @@ -278,7 +278,7 @@ public void onNext(T t) { b = predicate.test(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } if (b) { @@ -303,7 +303,7 @@ public boolean tryOnNext(T t) { b = predicate.test(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return false; } return b && actual.tryOnNext(t); diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFirstEmitting.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFirstEmitting.java index c5f98d6499..275ebe97d4 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFirstEmitting.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFirstEmitting.java @@ -68,7 +68,8 @@ public void subscribe(CoreSubscriber actual) { "The iterator returned is null"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, + actual.currentContext())); return; } @@ -80,7 +81,8 @@ public void subscribe(CoreSubscriber actual) { b = it.hasNext(); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, + actual.currentContext())); return; } @@ -95,7 +97,8 @@ public void subscribe(CoreSubscriber actual) { "The Publisher returned by the iterator is null"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, + actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFlatMap.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFlatMap.java index 1113a97a5f..25e999beb6 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFlatMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFlatMap.java @@ -126,7 +126,7 @@ static boolean trySubscribeScalarMap(Publisher source, t = ((Callable) source).call(); } catch (Throwable e) { - Operators.error(s, Operators.onOperatorError(e)); + Operators.error(s, Operators.onOperatorError(e, s.currentContext())); return true; } @@ -142,7 +142,7 @@ static boolean trySubscribeScalarMap(Publisher source, "The mapper returned a null Publisher"); } catch (Throwable e) { - Operators.error(s, Operators.onOperatorError(null, e, t)); + Operators.error(s, Operators.onOperatorError(null, e, t, s.currentContext())); return true; } @@ -153,7 +153,7 @@ static boolean trySubscribeScalarMap(Publisher source, v = ((Callable) p).call(); } catch (Throwable e) { - Operators.error(s, Operators.onOperatorError(null, e, t)); + Operators.error(s, Operators.onOperatorError(null, e, t, s.currentContext())); return true; } @@ -354,7 +354,7 @@ public void onNext(T t) { "The mapper returned a null Publisher"); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -364,7 +364,7 @@ public void onNext(T t) { v = ((Callable) p).call(); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } tryEmitScalar(v); @@ -620,7 +620,8 @@ else if (q != null) { v = q.poll(); } catch (Throwable ex) { - ex = Operators.onOperatorError(inner, ex); + ex = Operators.onOperatorError(inner, ex, + actual.currentContext()); if (!Exceptions.addThrowable(ERROR, this, ex)) { Operators.onErrorDropped(ex, actual.currentContext()); @@ -798,7 +799,7 @@ void innerError(FlatMapInner inner, Throwable e) { boolean failOverflow(R v, Subscription toCancel){ Throwable e = Operators.onOperatorError(toCancel, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), - v); + v, actual.currentContext()); if (!Exceptions.addThrowable(ERROR, this, e)) { Operators.onErrorDropped(e, actual.currentContext()); diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxFlattenIterable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxFlattenIterable.java index 470a36b9b8..3027ed62d1 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxFlattenIterable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxFlattenIterable.java @@ -77,7 +77,8 @@ public void subscribe(CoreSubscriber actual) { v = ((Callable) source).call(); } catch (Throwable ex) { - Operators.error(actual, Operators.onOperatorError(ex)); + Operators.error(actual, Operators.onOperatorError(ex, + actual.currentContext())); return; } @@ -94,7 +95,8 @@ public void subscribe(CoreSubscriber actual) { it = iter.iterator(); } catch (Throwable ex) { - Operators.error(actual, Operators.onOperatorError(ex)); + Operators.error(actual, Operators.onOperatorError(ex, + actual.currentContext())); return; } @@ -228,7 +230,8 @@ else if (m == Fuseable.ASYNC) { public void onNext(T t) { if (fusionMode != Fuseable.ASYNC) { if (!queue.offer(t)) { - onError(Operators.onOperatorError(s,Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL))); + onError(Operators.onOperatorError(s,Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), + actual.currentContext())); return; } } @@ -326,7 +329,8 @@ void drainAsync() { } catch (Throwable exc) { it = null; - onError(Operators.onOperatorError(s, exc, t)); + onError(Operators.onOperatorError(s, exc, t, + actual.currentContext())); continue; } @@ -372,7 +376,8 @@ void drainAsync() { "iterator returned null"); } catch (Throwable exc) { - onError(Operators.onOperatorError(s, exc)); + onError(Operators.onOperatorError(s, exc, + actual.currentContext())); continue; } @@ -392,7 +397,8 @@ void drainAsync() { b = it.hasNext(); } catch (Throwable exc) { - onError(Operators.onOperatorError(s, exc)); + onError(Operators.onOperatorError(s, exc, + actual.currentContext())); continue; } @@ -500,7 +506,8 @@ void drainSync() { } catch (Throwable exc) { current = null; - a.onError(Operators.onOperatorError(s, exc, t)); + a.onError(Operators.onOperatorError(s, exc, t, + actual.currentContext())); return; } @@ -530,7 +537,8 @@ void drainSync() { } catch (Throwable exc) { current = null; - a.onError(Operators.onOperatorError(s, exc)); + a.onError(Operators.onOperatorError(s, exc, + actual.currentContext())); return; } @@ -551,7 +559,8 @@ void drainSync() { } catch (Throwable exc) { current = null; - a.onError(Operators.onOperatorError(s, exc)); + a.onError(Operators.onOperatorError(s, exc, + actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxGenerate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxGenerate.java index bdcaaa970e..a716ca3d91 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxGenerate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxGenerate.java @@ -77,7 +77,7 @@ public void subscribe(CoreSubscriber actual) { try { state = stateSupplier.call(); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } actual.onSubscribe(new GenerateSubscription<>(actual, state, generator, stateConsumer)); @@ -219,7 +219,7 @@ void fastPath() { } catch (Throwable e) { cleanup(s); - actual.onError(Operators.onOperatorError(e)); + actual.onError(Operators.onOperatorError(e, actual.currentContext())); return; } if (terminate || cancelled) { diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxGroupBy.java b/reactor-core/src/main/java/reactor/core/publisher/FluxGroupBy.java index 33d7569a2b..e5a40af589 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxGroupBy.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxGroupBy.java @@ -186,7 +186,7 @@ public void onNext(T t) { value = Objects.requireNonNull(valueSelector.apply(t), "The valueSelector returned a null value"); } catch (Throwable ex) { - onError(Operators.onOperatorError(s, ex, t)); + onError(Operators.onOperatorError(s, ex, t, actual.currentContext())); return; } @@ -663,7 +663,8 @@ public void onNext(V t) { Subscriber a = actual; if (!queue.offer(t)) { - onError(Operators.onOperatorError(this, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t)); + onError(Operators.onOperatorError(this, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t, + actual.currentContext())); return; } if (outputFused) { diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxGroupJoin.java b/reactor-core/src/main/java/reactor/core/publisher/FluxGroupJoin.java index 940b9975c1..2d1da397c2 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxGroupJoin.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxGroupJoin.java @@ -328,7 +328,8 @@ void drain() { catch (Throwable exc) { Exceptions.addThrowable(ERROR, this, - Operators.onOperatorError(this, exc, left)); + Operators.onOperatorError(this, exc, left, + actual.currentContext())); errorAll(a); return; } @@ -355,7 +356,8 @@ void drain() { } catch (Throwable exc) { Exceptions.addThrowable(ERROR, - this, Operators.onOperatorError(this, exc, up)); + this, Operators.onOperatorError(this, exc, up, + actual.currentContext())); errorAll(a); return; } @@ -374,7 +376,8 @@ void drain() { Exceptions.addThrowable(ERROR, this, Operators.onOperatorError(this, - Exceptions.failWithOverflow())); + Exceptions.failWithOverflow(), + actual.currentContext())); errorAll(a); return; } @@ -412,7 +415,8 @@ else if (mode == RIGHT_VALUE) { catch (Throwable exc) { Exceptions.addThrowable(ERROR, this, - Operators.onOperatorError(this, exc, right)); + Operators.onOperatorError(this, exc, right, + actual.currentContext())); errorAll(a); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxHandle.java b/reactor-core/src/main/java/reactor/core/publisher/FluxHandle.java index aadf390646..b71cb1abd8 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxHandle.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxHandle.java @@ -97,7 +97,7 @@ public void onNext(T t) { handler.accept(t, this); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } R v = data; @@ -108,7 +108,8 @@ public void onNext(T t) { if(stop){ s.cancel(); if(error != null){ - onError(Operators.onOperatorError(null, error, t)); + onError(Operators.onOperatorError(null, error, t, + actual.currentContext())); return; } onComplete(); @@ -129,7 +130,7 @@ public boolean tryOnNext(T t) { handler.accept(t, this); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return false; } R v = data; @@ -140,7 +141,8 @@ public boolean tryOnNext(T t) { if(stop){ s.cancel(); if(error != null){ - onError(Operators.onOperatorError(null, error, t)); + onError(Operators.onOperatorError(null, error, t, + actual.currentContext())); } else { onComplete(); @@ -259,7 +261,7 @@ public void onNext(T t) { handler.accept(t, this); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } R v = data; @@ -270,7 +272,8 @@ public void onNext(T t) { if(done){ s.cancel(); if(error != null){ - actual.onError(Operators.onOperatorError(null, error, t)); + actual.onError(Operators.onOperatorError(null, error, t, + actual.currentContext())); return; } actual.onComplete(); @@ -291,7 +294,7 @@ public boolean tryOnNext(T t) { handler.accept(t, this); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return false; } R v = data; @@ -303,7 +306,8 @@ public boolean tryOnNext(T t) { if(done){ s.cancel(); if(error != null){ - actual.onError(Operators.onOperatorError(null, error, t)); + actual.onError(Operators.onOperatorError(null, error, t, + actual.currentContext())); } else { actual.onComplete(); diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxHandleFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxHandleFuseable.java index 0b5dd868fb..f835433b33 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxHandleFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxHandleFuseable.java @@ -104,7 +104,7 @@ public boolean tryOnNext(T t) { handler.accept(t, this); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return false; } R v = data; @@ -114,7 +114,8 @@ public boolean tryOnNext(T t) { } if (done) { if (error != null) { - actual.onError(Operators.onOperatorError(s, error, t)); + actual.onError(Operators.onOperatorError(s, error, t, + actual.currentContext())); } else { s.cancel(); @@ -148,7 +149,7 @@ public void onNext(T t) { handler.accept(t, this); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } R v = data; @@ -159,7 +160,8 @@ public void onNext(T t) { if (done) { s.cancel(); if (error != null) { - actual.onError(Operators.onOperatorError(null, error, t)); + actual.onError(Operators.onOperatorError(null, error, t, + actual.currentContext())); return; } actual.onComplete(); @@ -236,7 +238,7 @@ public R poll() { s.cancel(); if (error != null) { throw Exceptions.propagate(Operators.onOperatorError - (null, error, v)); + (null, error, v, actual.currentContext())); } else { actual.onComplete(); @@ -267,7 +269,7 @@ else if (dropped != 0L) { if (done) { if (error != null) { throw Exceptions.propagate(Operators.onOperatorError - (null, error, v)); + (null, error, v, actual.currentContext())); } return u; } @@ -380,7 +382,7 @@ public void onNext(T t) { handler.accept(t, this); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } R v = data; @@ -391,7 +393,8 @@ public void onNext(T t) { if (done) { s.cancel(); if (error != null) { - actual.onError(Operators.onOperatorError(null, error, v)); + actual.onError(Operators.onOperatorError(null, error, v, + actual.currentContext())); return; } actual.onComplete(); @@ -413,7 +416,7 @@ public boolean tryOnNext(T t) { handler.accept(t, this); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return false; } R v = data; @@ -425,7 +428,8 @@ public boolean tryOnNext(T t) { if (done) { s.cancel(); if (error != null) { - actual.onError(Operators.onOperatorError(null, error, v)); + actual.onError(Operators.onOperatorError(null, error, v, + actual.currentContext())); } else { actual.onComplete(); @@ -520,7 +524,7 @@ public R poll() { s.cancel(); if (error != null) { throw Exceptions.propagate(Operators.onOperatorError - (null, error, v)); + (null, error, v, actual.currentContext())); } else { actual.onComplete(); @@ -551,7 +555,7 @@ else if (dropped != 0L) { if (done) { if (error != null) { throw Exceptions.propagate(Operators.onOperatorError - (null, error, v)); + (null, error, v, actual.currentContext())); } return u; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxInterval.java b/reactor-core/src/main/java/reactor/core/publisher/FluxInterval.java index d1f26a59c3..52b189545e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxInterval.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxInterval.java @@ -69,7 +69,8 @@ public void subscribe(CoreSubscriber actual) { } catch (RejectedExecutionException ree) { if (!r.cancelled) { - actual.onError(Operators.onRejectedExecution(ree, r, null, null)); + actual.onError(Operators.onRejectedExecution(ree, r, null, null, + actual.currentContext())); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxIterable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxIterable.java index 0ec1a1a018..c44544ad74 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxIterable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxIterable.java @@ -48,7 +48,7 @@ public void subscribe(CoreSubscriber actual) { it = iterable.iterator(); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -75,7 +75,7 @@ static void subscribe(CoreSubscriber s, Iterator it) b = it.hasNext(); } catch (Throwable e) { - Operators.error(s, Operators.onOperatorError(e)); + Operators.error(s, Operators.onOperatorError(e, s.currentContext())); return; } if (!b) { diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxJoin.java b/reactor-core/src/main/java/reactor/core/publisher/FluxJoin.java index 1efee97fbd..d27fbf7c90 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxJoin.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxJoin.java @@ -279,7 +279,8 @@ void drain() { catch (Throwable exc) { Exceptions.addThrowable(ERROR, this, - Operators.onOperatorError(this, exc, left)); + Operators.onOperatorError(this, exc, left, + actual.currentContext())); errorAll(a); return; } @@ -314,7 +315,7 @@ void drain() { Exceptions.addThrowable(ERROR, this, Operators.onOperatorError(this, - exc, right)); + exc, right, actual.currentContext())); errorAll(a); return; } @@ -346,7 +347,8 @@ void drain() { Exceptions.addThrowable(ERROR, this, Operators.onOperatorError(this, - Exceptions.failWithOverflow())); + Exceptions.failWithOverflow(), + actual.currentContext())); errorAll(a); return; } @@ -373,7 +375,8 @@ else if (mode == RIGHT_VALUE) { catch (Throwable exc) { Exceptions.addThrowable(ERROR, this, - Operators.onOperatorError(this, exc, right)); + Operators.onOperatorError(this, exc, right, + actual.currentContext())); errorAll(a); return; } @@ -407,7 +410,8 @@ else if (mode == RIGHT_VALUE) { catch (Throwable exc) { Exceptions.addThrowable(ERROR, this, - Operators.onOperatorError(this, exc, left)); + Operators.onOperatorError(this, exc, left, + actual.currentContext())); errorAll(a); return; } @@ -439,7 +443,8 @@ else if (mode == RIGHT_VALUE) { Exceptions.addThrowable(ERROR, this, Operators.onOperatorError(this, - Exceptions.failWithOverflow())); + Exceptions.failWithOverflow(), + actual.currentContext())); errorAll(a); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMap.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMap.java index cbe742a0be..abe66feacd 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMap.java @@ -101,7 +101,7 @@ public void onNext(T t) { "The mapper returned a null value."); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -194,7 +194,7 @@ public void onNext(T t) { "The mapper returned a null value."); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -216,7 +216,7 @@ public boolean tryOnNext(T t) { } catch (Throwable e) { done = true; - actual.onError(Operators.onOperatorError(s, e, t)); + actual.onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return true; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMapFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMapFuseable.java index 75690abfff..283c7073a6 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMapFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMapFuseable.java @@ -108,7 +108,7 @@ public void onNext(T t) { "The mapper returned a null value."); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -259,7 +259,7 @@ public void onNext(T t) { "The mapper returned a null value."); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -281,7 +281,7 @@ public boolean tryOnNext(T t) { "The mapper returned a null value."); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return true; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMapSignal.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMapSignal.java index a71fc9634b..a30f627efc 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMapSignal.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMapSignal.java @@ -139,7 +139,7 @@ public void onNext(T t) { } catch (Throwable e) { done = true; - actual.onError(Operators.onOperatorError(s, e, t)); + actual.onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -169,7 +169,7 @@ public void onError(Throwable t) { } catch (Throwable e) { done = true; - actual.onError(Operators.onOperatorError(s, e, t)); + actual.onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -201,7 +201,7 @@ public void onComplete() { } catch (Throwable e) { done = true; - actual.onError(Operators.onOperatorError(s, e)); + actual.onError(Operators.onOperatorError(s, e, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxMergeSequential.java b/reactor-core/src/main/java/reactor/core/publisher/FluxMergeSequential.java index ee58e6238a..f83808995d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxMergeSequential.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxMergeSequential.java @@ -201,7 +201,7 @@ public void onNext(T t) { publisher = Objects.requireNonNull(mapper.apply(t), "publisher"); } catch (Throwable ex) { - onError(Operators.onOperatorError(s, ex, t)); + onError(Operators.onOperatorError(s, ex, t, actual.currentContext())); return; } @@ -219,7 +219,7 @@ public void onNext(T t) { new IllegalStateException("Too many subscribers for " + "fluxMergeSequential on item: " + t + "; subscribers: " + badSize), - t)); + t, actual.currentContext())); return; } @@ -294,7 +294,8 @@ void innerNext(MergeSequentialInner inner, R value) { } else { inner.cancel(); - onError(Operators.onOperatorError(null, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), value)); + onError(Operators.onOperatorError(null, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), value, + actual.currentContext())); } } @@ -396,7 +397,8 @@ void drain() { catch (Throwable ex) { current = null; inner.cancel(); - ex = Operators.onOperatorError(ex); + ex = Operators.onOperatorError(ex, + actual.currentContext()); cancelAll(); a.onError(ex); return; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBuffer.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBuffer.java index eeab73cb93..637cc324bb 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBuffer.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBuffer.java @@ -147,7 +147,8 @@ public void onNext(T t) { } if (!queue.offer(t)) { Throwable ex = - Operators.onOperatorError(s, Exceptions.failWithOverflow(), t); + Operators.onOperatorError(s, Exceptions.failWithOverflow(), t, + actual.currentContext()); if (onOverflow != null) { try { onOverflow.accept(t); diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferStrategy.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferStrategy.java index eddf6993b0..7bc5a7bacd 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferStrategy.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferStrategy.java @@ -166,14 +166,16 @@ public void onNext(T t) { onOverflow.accept(overflowElement); } catch (Throwable e) { - Throwable ex = Operators.onOperatorError(s, e, overflowElement); + Throwable ex = Operators.onOperatorError(s, e, overflowElement, + actual.currentContext()); onError(ex); return; } } if (callOnError) { - Throwable ex = Operators.onOperatorError(s, Exceptions.failWithOverflow(), overflowElement); + Throwable ex = Operators.onOperatorError(s, Exceptions.failWithOverflow(), overflowElement, + actual.currentContext()); onError(ex); } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferTimeout.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferTimeout.java index 327a83b52a..8d451a4f1c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferTimeout.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureBufferTimeout.java @@ -222,7 +222,8 @@ public void onNext(T t) { } catch (RejectedExecutionException re) { done = true; - error = Operators.onRejectedExecution(re, this, null, t); + error = Operators.onRejectedExecution(re, this, null, t, + actual.currentContext()); } drain(); } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureDrop.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureDrop.java index 0947f957bd..b8342757dd 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureDrop.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnBackpressureDrop.java @@ -128,7 +128,7 @@ public void onNext(T t) { onDrop.accept(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxOnErrorResume.java b/reactor-core/src/main/java/reactor/core/publisher/FluxOnErrorResume.java index 22c7f6182a..12d730c839 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxOnErrorResume.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxOnErrorResume.java @@ -88,7 +88,7 @@ public void onError(Throwable t) { "The nextFactory returned a null Publisher"); } catch (Throwable e) { - Throwable _e = Operators.onOperatorError(e); + Throwable _e = Operators.onOperatorError(e, actual.currentContext()); if (t != _e) { _e.addSuppressed(t); } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPeek.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPeek.java index fa0d3e6347..e5c486b16e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPeek.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPeek.java @@ -124,7 +124,7 @@ public void request(long n) { requestHook.accept(n); } catch (Throwable e) { - Operators.onOperatorError(e); + Operators.onOperatorError(e, actual.currentContext()); } } s.request(n); @@ -138,7 +138,7 @@ public void cancel() { cancelHook.run(); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e)); + onError(Operators.onOperatorError(s, e, actual.currentContext())); return; } } @@ -154,7 +154,8 @@ public void onSubscribe(Subscription s) { subscribeHook.accept(s); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(s, e)); + Operators.error(actual, Operators.onOperatorError(s, e, + actual.currentContext())); return; } } @@ -176,7 +177,7 @@ public void onNext(T t) { nextHook.accept(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } } @@ -198,7 +199,7 @@ public void onError(Throwable t) { } catch (Throwable e) { //this performs a throwIfFatal or suppresses t in e - t = Operators.onOperatorError(null, e, t); + t = Operators.onOperatorError(null, e, t, actual.currentContext()); } } @@ -235,7 +236,7 @@ public void onComplete() { completeHook.run(); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e)); + onError(Operators.onOperatorError(s, e, actual.currentContext())); return; } } @@ -308,7 +309,7 @@ public Runnable onCancelCall() { * callback that fails during onComplete. It drops the error to the global hook. *

      *
    • The callback failure is thrown immediately if fatal.
    • - *
    • {@link Operators#onOperatorError(Throwable)} is called
    • + *
    • {@link Operators#onOperatorError(Throwable, Context)} is called
    • *
    • {@link Operators#onErrorDropped(Throwable, Context)} is called
    • *
    *

    @@ -322,7 +323,7 @@ static void afterCompleteWithFailure(SignalPeek parent, Throwable callbackFailure, Context context) { Exceptions.throwIfFatal(callbackFailure); - Throwable _e = Operators.onOperatorError(callbackFailure); + Throwable _e = Operators.onOperatorError(callbackFailure, context); Operators.onErrorDropped(_e, context); } @@ -331,7 +332,7 @@ static void afterCompleteWithFailure(SignalPeek parent, * callback that fails during onError. It drops the error to the global hook. *

      *
    • The callback failure is thrown immediately if fatal.
    • - *
    • {@link Operators#onOperatorError(Subscription, Throwable, Object)} is + *
    • {@link Operators#onOperatorError(Subscription, Throwable, Object, Context)} is * called, adding the original error as suppressed
    • *
    • {@link Operators#onErrorDropped(Throwable, Context)} is called
    • *
    @@ -346,7 +347,7 @@ static void afterCompleteWithFailure(SignalPeek parent, static void afterErrorWithFailure(SignalPeek parent, Throwable callbackFailure, Throwable originalError, Context context) { Exceptions.throwIfFatal(callbackFailure); - Throwable _e = Operators.onOperatorError(null, callbackFailure, originalError); + Throwable _e = Operators.onOperatorError(null, callbackFailure, originalError, context); Operators.onErrorDropped(_e, context); } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPeekFuseable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPeekFuseable.java index a48ca49fa2..735140db3e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPeekFuseable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPeekFuseable.java @@ -132,7 +132,7 @@ public void request(long n) { requestHook.accept(n); } catch (Throwable e) { - Operators.onOperatorError(e); + Operators.onOperatorError(e, actual.currentContext()); } } s.request(n); @@ -146,7 +146,7 @@ public void cancel() { cancelHook.run(); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e)); + onError(Operators.onOperatorError(s, e, actual.currentContext())); return; } } @@ -163,7 +163,8 @@ public void onSubscribe(Subscription s) { subscribeHook.accept(s); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(s, e)); + Operators.error(actual, Operators.onOperatorError(s, e, + actual.currentContext())); return; } } @@ -189,7 +190,8 @@ public void onNext(T t) { nextHook.accept(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, + actual.currentContext())); return; } } @@ -212,7 +214,7 @@ public void onError(Throwable t) { } catch (Throwable e) { //this performs a throwIfFatal or suppresses t in e - t = Operators.onOperatorError(null, e, t); + t = Operators.onOperatorError(null, e, t, actual.currentContext()); } } @@ -254,7 +256,7 @@ public void onComplete() { completeHook.run(); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e)); + onError(Operators.onOperatorError(s, e, actual.currentContext())); return; } } @@ -294,10 +296,12 @@ public T poll() { errorHook.accept(e); } catch (Throwable errorCallbackError) { - throw Exceptions.propagate(Operators.onOperatorError(s, errorCallbackError, e)); + throw Exceptions.propagate(Operators.onOperatorError(s, errorCallbackError, e, + actual.currentContext())); } } - throw Exceptions.propagate(Operators.onOperatorError(s, e)); + throw Exceptions.propagate(Operators.onOperatorError(s, e, + actual.currentContext())); } final Consumer nextHook = parent.onNextCall(); @@ -306,7 +310,8 @@ public T poll() { nextHook.accept(v); } catch (Throwable e) { - throw Exceptions.propagate(Operators.onOperatorError(s, e, v)); + throw Exceptions.propagate(Operators.onOperatorError(s, e, v, + actual.currentContext())); } } if (v == null && (d || sourceMode == SYNC)) { @@ -398,7 +403,7 @@ public void request(long n) { requestHook.accept(n); } catch (Throwable e) { - Operators.onOperatorError(e); + Operators.onOperatorError(e, actual.currentContext()); } } s.request(n); @@ -412,7 +417,7 @@ public void cancel() { cancelHook.run(); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e)); + onError(Operators.onOperatorError(s, e, actual.currentContext())); return; } } @@ -429,7 +434,8 @@ public void onSubscribe(Subscription s) { subscribeHook.accept(s); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(s, e)); + Operators.error(actual, Operators.onOperatorError(s, e, + actual.currentContext())); return; } } @@ -455,7 +461,8 @@ public void onNext(T t) { nextHook.accept(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, + actual.currentContext())); return; } } @@ -476,7 +483,7 @@ public boolean tryOnNext(T t) { nextHook.accept(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return true; } } @@ -498,7 +505,7 @@ public void onError(Throwable t) { } catch (Throwable e) { //this performs a throwIfFatal or suppresses t in e - t = Operators.onOperatorError(null, e, t); + t = Operators.onOperatorError(null, e, t, actual.currentContext()); } } @@ -540,7 +547,7 @@ public void onComplete() { completeHook.run(); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e)); + onError(Operators.onOperatorError(s, e, actual.currentContext())); return; } } @@ -579,10 +586,12 @@ public T poll() { errorHook.accept(e); } catch (Throwable errorCallbackError) { - throw Exceptions.propagate(Operators.onOperatorError(s, errorCallbackError, e)); + throw Exceptions.propagate(Operators.onOperatorError(s, errorCallbackError, e, + actual.currentContext())); } } - throw Exceptions.propagate(Operators.onOperatorError(s, e)); + throw Exceptions.propagate(Operators.onOperatorError(s, e, + actual.currentContext())); } final Consumer nextHook = parent.onNextCall(); @@ -591,7 +600,8 @@ public T poll() { nextHook.accept(v); } catch (Throwable e) { - throw Exceptions.propagate(Operators.onOperatorError(s, e, v)); + throw Exceptions.propagate(Operators.onOperatorError(s, e, v, + actual.currentContext())); } } if (v == null && (d || sourceMode == SYNC)) { @@ -712,7 +722,7 @@ public void request(long n) { requestHook.accept(n); } catch (Throwable e) { - Operators.onOperatorError(e); + Operators.onOperatorError(e, actual.currentContext()); } } s.request(n); @@ -726,7 +736,7 @@ public void cancel() { cancelHook.run(); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e)); + onError(Operators.onOperatorError(s, e, actual.currentContext())); return; } } @@ -742,7 +752,8 @@ public void onSubscribe(Subscription s) { subscribeHook.accept(s); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(s, e)); + Operators.error(actual, Operators.onOperatorError(s, e, + actual.currentContext())); return; } } @@ -773,7 +784,7 @@ public void onNext(T t) { nextHook.accept(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } } @@ -793,7 +804,7 @@ public boolean tryOnNext(T t) { nextHook.accept(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return true; } } @@ -815,7 +826,7 @@ public void onError(Throwable t) { } catch (Throwable e) { //this performs a throwIfFatal or suppresses t in e - t = Operators.onOperatorError(null, e, t); + t = Operators.onOperatorError(null, e, t, actual.currentContext()); } } @@ -851,7 +862,7 @@ public void onComplete() { completeHook.run(); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e)); + onError(Operators.onOperatorError(s, e, actual.currentContext())); return; } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPublish.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPublish.java index 3542bd26b3..5d1db15fa6 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPublish.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPublish.java @@ -242,7 +242,7 @@ else if (m == Fuseable.ASYNC) { public void onNext(T t) { if (done) { if (t != null) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, currentContext()); } return; } @@ -253,8 +253,7 @@ public void onNext(T t) { if (!queue.offer(t)) { Throwable ex = Operators.onOperatorError(s, - Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), - t); + Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t, currentContext()); if (!Exceptions.addThrowable(ERROR, this, ex)) { Operators.onErrorDropped(ex); return; @@ -414,7 +413,7 @@ final void drain() { catch (Throwable ex) { Exceptions.addThrowable(ERROR, this, - Operators.onOperatorError(s, ex)); + Operators.onOperatorError(s, ex, currentContext())); d = true; v = null; } @@ -439,7 +438,7 @@ final void drain() { catch (Throwable ex) { Exceptions.addThrowable(ERROR, this, - Operators.onOperatorError(s, ex)); + Operators.onOperatorError(s, ex, currentContext())); d = true; v = null; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPublishMulticast.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPublishMulticast.java index f92fac915f..b233190189 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPublishMulticast.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPublishMulticast.java @@ -83,7 +83,7 @@ public void subscribe(CoreSubscriber actual) { "The transform returned a null Publisher"); } catch (Throwable ex) { - Operators.error(actual, Operators.onOperatorError(ex)); + Operators.error(actual, Operators.onOperatorError(ex, actual.currentContext())); return; } @@ -256,7 +256,7 @@ public void onNext(T t) { if (!queue.offer(t)) { onError(Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), - t)); + t, context)); return; } } @@ -334,7 +334,7 @@ void drainSync() { v = queue.poll(); } catch (Throwable ex) { - error = Operators.onOperatorError(s, ex); + error = Operators.onOperatorError(s, ex, context); queue.clear(); a = SUBSCRIBERS.getAndSet(this, TERMINATED); n = a.length; @@ -432,7 +432,7 @@ void drainAsync() { } catch (Throwable ex) { queue.clear(); - error = Operators.onOperatorError(s, ex); + error = Operators.onOperatorError(s, ex, context); a = SUBSCRIBERS.getAndSet(this, TERMINATED); n = a.length; for (int i = 0; i < n; i++) { diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPublishOn.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPublishOn.java index e1d8675159..3459287ebe 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPublishOn.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPublishOn.java @@ -79,7 +79,7 @@ public void subscribe(CoreSubscriber actual) { "The scheduler returned a null worker"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -226,7 +226,7 @@ public void onNext(T t) { if (!queue.offer(t)) { error = Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), - t); + t, actual.currentContext()); done = true; } trySchedule(this, null, t); @@ -290,7 +290,8 @@ void trySchedule( } catch (RejectedExecutionException ree) { queue.clear(); - actual.onError(Operators.onRejectedExecution(ree, subscription, suppressed, dataSignal)); + actual.onError(Operators.onRejectedExecution(ree, subscription, suppressed, dataSignal, + actual.currentContext())); } } @@ -313,7 +314,8 @@ void runSync() { v = q.poll(); } catch (Throwable ex) { - doError(a, Operators.onOperatorError(s, ex)); + doError(a, Operators.onOperatorError(s, ex, + actual.currentContext())); return; } @@ -377,7 +379,7 @@ void runAsync() { s.cancel(); q.clear(); - doError(a, Operators.onOperatorError(ex)); + doError(a, Operators.onOperatorError(ex, actual.currentContext())); return; } @@ -703,7 +705,8 @@ public void onNext(T t) { return; } if (!queue.offer(t)) { - error = Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t); + error = Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t, + actual.currentContext()); done = true; } trySchedule(this, null, t); @@ -765,7 +768,8 @@ void trySchedule( } catch (RejectedExecutionException ree) { queue.clear(); - actual.onError(Operators.onRejectedExecution(ree, subscription, suppressed, dataSignal)); + actual.onError(Operators.onRejectedExecution(ree, subscription, suppressed, dataSignal, + actual.currentContext())); } } @@ -787,7 +791,8 @@ void runSync() { v = q.poll(); } catch (Throwable ex) { - doError(a, Operators.onOperatorError(s, ex)); + doError(a, Operators.onOperatorError(s, ex, + actual.currentContext())); return; } @@ -851,7 +856,7 @@ void runAsync() { s.cancel(); q.clear(); - doError(a, Operators.onOperatorError(ex)); + doError(a, Operators.onOperatorError(ex, actual.currentContext())); return; } boolean empty = v == null; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxRepeatPredicate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxRepeatPredicate.java index e6a713e817..77caea275a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxRepeatPredicate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxRepeatPredicate.java @@ -85,7 +85,7 @@ public void onComplete() { try { b = predicate.getAsBoolean(); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(e)); + actual.onError(Operators.onOperatorError(e, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxRepeatWhen.java b/reactor-core/src/main/java/reactor/core/publisher/FluxRepeatWhen.java index 6b61fb3c2f..579176e787 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxRepeatWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxRepeatWhen.java @@ -74,7 +74,7 @@ public void subscribe(CoreSubscriber actual) { "The whenSourceFactory returned a null Publisher"); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(e)); + actual.onError(Operators.onOperatorError(e, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxReplay.java b/reactor-core/src/main/java/reactor/core/publisher/FluxReplay.java index f6809126c7..edef02f606 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxReplay.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxReplay.java @@ -1151,7 +1151,7 @@ else if (Operators.setOnce(S, this, s)) { public void onNext(T t) { ReplayBuffer b = buffer; if (b.isDone()) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, currentContext()); } else { b.add(t); @@ -1165,7 +1165,7 @@ public void onNext(T t) { public void onError(Throwable t) { ReplayBuffer b = buffer; if (b.isDone()) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, currentContext()); } else { b.onError(t); diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxRetryPredicate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxRetryPredicate.java index 3fe35bec25..856391a31a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxRetryPredicate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxRetryPredicate.java @@ -87,7 +87,7 @@ public void onError(Throwable t) { try { b = predicate.test(t); } catch (Throwable e) { - Throwable _t = Operators.onOperatorError(e); + Throwable _t = Operators.onOperatorError(e, actual.currentContext()); if (_t != t) { _t.addSuppressed(t); } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxRetryWhen.java b/reactor-core/src/main/java/reactor/core/publisher/FluxRetryWhen.java index aa8253ba47..7f8dd0d7d5 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxRetryWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxRetryWhen.java @@ -71,7 +71,7 @@ static void subscribe(CoreSubscriber s, Function actual) { "The stream returned a null Iterator"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOn.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOn.java index 5167a75af6..43d415eef5 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOn.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOn.java @@ -57,7 +57,7 @@ public void subscribe(CoreSubscriber actual) { worker = Objects.requireNonNull(scheduler.createWorker(), "The scheduler returned a null Function"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -70,7 +70,8 @@ public void subscribe(CoreSubscriber actual) { } catch (RejectedExecutionException ree) { if (parent.s != Operators.cancelledSubscription()) { - actual.onError(Operators.onRejectedExecution(ree, parent, null, null)); + actual.onError(Operators.onRejectedExecution(ree, parent, null, null, + actual.currentContext())); } } } @@ -138,7 +139,8 @@ void requestUpstream(final long n, final Subscription s) { //FIXME should not throw but if we implement strict // serialization like in StrictSubscriber, onNext will carry an // extra cost - throw Operators.onRejectedExecution(ree, this, null, null); + throw Operators.onRejectedExecution(ree, this, null, null, + actual.currentContext()); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnCallable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnCallable.java index 9807ebec7b..ca5fe19871 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnCallable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnCallable.java @@ -57,7 +57,7 @@ public void subscribe(CoreSubscriber actual) { } catch (RejectedExecutionException ree) { if(parent.state != CallableSubscribeOnSubscription.HAS_CANCELLED) { - actual.onError(Operators.onRejectedExecution(ree)); + actual.onError(Operators.onRejectedExecution(ree, actual.currentContext())); } } } @@ -216,7 +216,8 @@ public void run() { v = callable.call(); } catch (Throwable ex) { - actual.onError(Operators.onOperatorError(this, ex)); + actual.onError(Operators.onOperatorError(this, ex, + actual.currentContext())); return; } @@ -262,7 +263,8 @@ public void request(long n) { setRequestFuture(f); } catch (RejectedExecutionException ree) { - actual.onError(Operators.onRejectedExecution(ree)); + actual.onError(Operators.onRejectedExecution(ree, + actual.currentContext())); } } return; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnValue.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnValue.java index 78fd43fb2e..b8e1cfcbf9 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnValue.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSubscribeOnValue.java @@ -59,7 +59,8 @@ public void subscribe(CoreSubscriber actual) { } catch (RejectedExecutionException ree) { if (parent.future != OperatorDisposables.DISPOSED) { - actual.onError(Operators.onRejectedExecution(ree)); + actual.onError(Operators.onRejectedExecution(ree, + actual.currentContext())); } } } @@ -141,7 +142,7 @@ public void request(long n) { actual.onError(Operators.onRejectedExecution(ree, this, null, - value)); + value, actual.currentContext())); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxSwitchMap.java b/reactor-core/src/main/java/reactor/core/publisher/FluxSwitchMap.java index 0416ee41f7..58a6fd9f58 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxSwitchMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxSwitchMap.java @@ -215,7 +215,7 @@ public void onNext(T t) { "The mapper returned a null publisher"); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntil.java b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntil.java index 2006ed1ea7..93eda06550 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntil.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeUntil.java @@ -81,7 +81,7 @@ public void onNext(T t) { try { b = predicate.test(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeWhile.java b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeWhile.java index c9f1b3b088..e099781e21 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxTakeWhile.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxTakeWhile.java @@ -78,7 +78,7 @@ public void onNext(T t) { try { b = predicate.test(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxTimeout.java b/reactor-core/src/main/java/reactor/core/publisher/FluxTimeout.java index 11526492ee..46cf982585 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxTimeout.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxTimeout.java @@ -153,7 +153,8 @@ public void onNext(T t) { "The itemTimeout returned a null Publisher"); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(this, e, t)); + actual.onError(Operators.onOperatorError(this, e, t, + actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxUsing.java b/reactor-core/src/main/java/reactor/core/publisher/FluxUsing.java index 8d82155fc2..86509f9bb3 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxUsing.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxUsing.java @@ -74,7 +74,7 @@ public void subscribe(CoreSubscriber actual) { resource = resourceSupplier.call(); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -90,11 +90,11 @@ public void subscribe(CoreSubscriber actual) { resourceCleanup.accept(resource); } catch (Throwable ex) { - ex.addSuppressed(Operators.onOperatorError(e)); + ex.addSuppressed(Operators.onOperatorError(e, actual.currentContext())); e = ex; } - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -202,7 +202,7 @@ public void onError(Throwable t) { resourceCleanup.accept(resource); } catch (Throwable e) { - Throwable _e = Operators.onOperatorError(e); + Throwable _e = Operators.onOperatorError(e, actual.currentContext()); if (_e != t) { _e.addSuppressed(t); } @@ -224,7 +224,7 @@ public void onComplete() { resourceCleanup.accept(resource); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(e)); + actual.onError(Operators.onOperatorError(e, actual.currentContext())); return; } } @@ -355,7 +355,7 @@ public void onError(Throwable t) { resourceCleanup.accept(resource); } catch (Throwable e) { - Throwable _e = Operators.onOperatorError(e); + Throwable _e = Operators.onOperatorError(e, actual.currentContext()); if (_e != t) { _e.addSuppressed(t); } @@ -377,7 +377,7 @@ public void onComplete() { resourceCleanup.accept(resource); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(e)); + actual.onError(Operators.onOperatorError(e, actual.currentContext())); return; } } @@ -519,7 +519,7 @@ public void onError(Throwable t) { resourceCleanup.accept(resource); } catch (Throwable e) { - Throwable _e = Operators.onOperatorError(e); + Throwable _e = Operators.onOperatorError(e, actual.currentContext()); if (_e != t) { _e.addSuppressed(t); } @@ -541,7 +541,7 @@ public void onComplete() { resourceCleanup.accept(resource); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(e)); + actual.onError(Operators.onOperatorError(e, actual.currentContext())); return; } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowPredicate.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowPredicate.java index 98bb884940..4397657c08 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowPredicate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowPredicate.java @@ -202,7 +202,8 @@ void offerNewWindow(@Nullable T emitInNewWindow) { window = g; if (!queue.offer(g)) { - onError(Operators.onOperatorError(this, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), emitInNewWindow)); + onError(Operators.onOperatorError(this, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), emitInNewWindow, + actual.currentContext())); return; } drain(); @@ -222,7 +223,7 @@ public void onNext(T t) { match = predicate.test(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -705,7 +706,8 @@ public void onNext(T t) { Subscriber a = actual; if (!queue.offer(t)) { - onError(Operators.onOperatorError(this, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t)); + onError(Operators.onOperatorError(this, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t, + actual.currentContext())); return; } if (enableOperatorFusion) { diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowTimeOrSize.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowTimeOrSize.java index 508f319b1c..527cafb65e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowTimeOrSize.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowTimeOrSize.java @@ -194,7 +194,8 @@ void subscribeAndCreateWindow() { //or the first emission, which will follow the subscribe } catch (RejectedExecutionException ree) { - RuntimeException error = Operators.onRejectedExecution(ree, subscription, null, null); + RuntimeException error = Operators.onRejectedExecution(ree, subscription, null, null, + actual.currentContext()); Operators.error(actual, error); } } @@ -235,7 +236,7 @@ boolean timerStart() { return true; } catch (RejectedExecutionException ree) { - onError(Operators.onRejectedExecution(ree)); + onError(Operators.onRejectedExecution(ree, actual.currentContext())); return false; } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowWhen.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowWhen.java index 242c2573cc..acd262c66c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWindowWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWindowWhen.java @@ -402,7 +402,7 @@ else if (windowCount == 0) { this, Operators.onOperatorError(s, ex, - newWindow.value)); + newWindow.value, actual.currentContext())); continue; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxWithLatestFrom.java b/reactor-core/src/main/java/reactor/core/publisher/FluxWithLatestFrom.java index cf13c19edd..a2447b696e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxWithLatestFrom.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxWithLatestFrom.java @@ -187,7 +187,7 @@ public void onNext(T t) { "The combiner returned a null value"); } catch (Throwable e) { - onError(Operators.onOperatorError(this, e, t)); + onError(Operators.onOperatorError(this, e, t, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxZip.java b/reactor-core/src/main/java/reactor/core/publisher/FluxZip.java index 0bbcc55319..37b28752e3 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxZip.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxZip.java @@ -153,7 +153,8 @@ void handleIterableMode(CoreSubscriber s, if (p == null) { Operators.error(s, Operators.onOperatorError(new NullPointerException( - "The sourcesIterable returned a null Publisher"))); + "The sourcesIterable returned a null Publisher"), + s.currentContext())); return; } @@ -166,7 +167,8 @@ void handleIterableMode(CoreSubscriber s, v = callable.call(); } catch (Throwable e) { - Operators.error(s, Operators.onOperatorError(e)); + Operators.error(s, Operators.onOperatorError(e, + s.currentContext())); return; } @@ -243,7 +245,8 @@ void handleArrayMode(CoreSubscriber s, Publisher[] srcs) v = ((Callable) p).call(); } catch (Throwable e) { - Operators.error(s, Operators.onOperatorError(e)); + Operators.error(s, Operators.onOperatorError(e, + s.currentContext())); return; } @@ -306,7 +309,7 @@ void handleBoth(CoreSubscriber s, "The zipper returned a null value"); } catch (Throwable e) { - s.onError(Operators.onOperatorError(e)); + s.onError(Operators.onOperatorError(e, s.currentContext())); return; } @@ -379,7 +382,8 @@ void next(T value, int index) { "The zipper returned a null value"); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(this, e, value)); + actual.onError(Operators.onOperatorError(this, e, value, + actual.currentContext())); return; } @@ -682,7 +686,8 @@ void drain() { } } catch (Throwable ex) { - ex = Operators.onOperatorError(ex); + ex = Operators.onOperatorError(ex, + actual.currentContext()); cancelAll(); @@ -708,7 +713,8 @@ void drain() { } catch (Throwable ex) { - ex = Operators.onOperatorError(null, ex, values.clone()); + ex = Operators.onOperatorError(null, ex, values.clone(), + actual.currentContext()); cancelAll(); Exceptions.addThrowable(ERROR, this, ex); @@ -762,7 +768,8 @@ void drain() { } } catch (Throwable ex) { - ex = Operators.onOperatorError(null, ex, values); + ex = Operators.onOperatorError(null, ex, values, + actual.currentContext()); cancelAll(); @@ -873,7 +880,8 @@ else if (m == ASYNC) { public void onNext(T t) { if (sourceMode != ASYNC) { if (!queue.offer(t)) { - onError(Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t)); + onError(Operators.onOperatorError(s, Exceptions.failWithOverflow + (Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), currentContext())); return; } } @@ -888,7 +896,7 @@ public Context currentContext() { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t, parent.actual.currentContext()); + Operators.onErrorDropped(t, currentContext()); return; } done = true; diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxZipIterable.java b/reactor-core/src/main/java/reactor/core/publisher/FluxZipIterable.java index 0997a37dfb..75db019afb 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxZipIterable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxZipIterable.java @@ -56,7 +56,7 @@ public void subscribe(CoreSubscriber actual) { "The other iterable produced a null iterator"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -66,7 +66,7 @@ public void subscribe(CoreSubscriber actual) { b = it.hasNext(); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -130,7 +130,7 @@ public void onNext(T t) { } catch (Throwable e) { done = true; - actual.onError(Operators.onOperatorError(s, e, t)); + actual.onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -142,7 +142,7 @@ public void onNext(T t) { } catch (Throwable e) { done = true; - actual.onError(Operators.onOperatorError(s, e, t)); + actual.onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } @@ -155,7 +155,7 @@ public void onNext(T t) { } catch (Throwable e) { done = true; - actual.onError(Operators.onOperatorError(s, e, t)); + actual.onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/LambdaMonoSubscriber.java b/reactor-core/src/main/java/reactor/core/publisher/LambdaMonoSubscriber.java index 4ee8734fcf..1e4646f294 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/LambdaMonoSubscriber.java +++ b/reactor-core/src/main/java/reactor/core/publisher/LambdaMonoSubscriber.java @@ -128,7 +128,7 @@ void doError(Throwable t) { public final void onNext(T x) { Subscription s = S.getAndSet(this, Operators.cancelledSubscription()); if (s == Operators.cancelledSubscription()) { - Operators.onNextDropped(x); + Operators.onNextDropped(x, currentContext()); return; } if (consumer != null) { diff --git a/reactor-core/src/main/java/reactor/core/publisher/Mono.java b/reactor-core/src/main/java/reactor/core/publisher/Mono.java index 03d48c1971..143ed6c49d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/Mono.java +++ b/reactor-core/src/main/java/reactor/core/publisher/Mono.java @@ -2159,7 +2159,7 @@ public final Mono doOnError(Predicate predicate, * Add behavior triggering a {@link LongConsumer} when the {@link Mono} receives any request. *

    * Note that non fatal error raised in the callback will not be propagated and - * will simply trigger {@link Operators#onOperatorError(Throwable)}. + * will simply trigger {@link Operators#onOperatorError(Throwable, Context)}. * *

    * diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoAll.java b/reactor-core/src/main/java/reactor/core/publisher/MonoAll.java index afe63f8e51..dec5d2fa89 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoAll.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoAll.java @@ -98,7 +98,7 @@ public void onNext(T t) { b = predicate.test(t); } catch (Throwable e) { done = true; - actual.onError(Operators.onOperatorError(s, e, t)); + actual.onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } if (!b) { diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoAny.java b/reactor-core/src/main/java/reactor/core/publisher/MonoAny.java index 5f4b52f4b1..30757bf428 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoAny.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoAny.java @@ -99,7 +99,7 @@ public void onNext(T t) { b = predicate.test(t); } catch (Throwable e) { done = true; - actual.onError(Operators.onOperatorError(s, e, t)); + actual.onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return; } if (b) { diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCallable.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCallable.java index 4b702919df..888898c76e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCallable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCallable.java @@ -58,7 +58,7 @@ public void subscribe(CoreSubscriber actual) { t = Objects.requireNonNull(callable.call(), "callable returned null"); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(e)); + actual.onError(Operators.onOperatorError(e, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCollect.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCollect.java index 3a5b2ede5a..7e612fffa7 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCollect.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCollect.java @@ -59,7 +59,7 @@ public void subscribe(CoreSubscriber actual) { "The supplier returned a null container"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -119,7 +119,7 @@ public void onNext(T t) { action.accept(value, t); } catch (Throwable e) { - onError(Operators.onOperatorError(this, e, t)); + onError(Operators.onOperatorError(this, e, t, actual.currentContext())); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCollectList.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCollectList.java index 57d63fff77..0dc8f08837 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCollectList.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCollectList.java @@ -52,7 +52,7 @@ public void subscribe(CoreSubscriber actual) { "The collectionSupplier returned a null collection"); } catch (Throwable ex) { - Operators.error(actual, Operators.onOperatorError(ex)); + Operators.error(actual, Operators.onOperatorError(ex, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCreate.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCreate.java index 60f690f7b8..ac7b0bca06 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCreate.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCreate.java @@ -53,7 +53,7 @@ public void subscribe(CoreSubscriber actual) { callback.accept(emitter); } catch (Throwable ex) { - emitter.error(Operators.onOperatorError(ex)); + emitter.error(Operators.onOperatorError(ex, actual.currentContext())); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoDefer.java b/reactor-core/src/main/java/reactor/core/publisher/MonoDefer.java index ac626e9342..20e3804500 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoDefer.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoDefer.java @@ -45,7 +45,7 @@ public void subscribe(CoreSubscriber actual) { "The Mono returned by the supplier is null"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoDelay.java b/reactor-core/src/main/java/reactor/core/publisher/MonoDelay.java index 34575815e0..3b8d25a457 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoDelay.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoDelay.java @@ -58,7 +58,8 @@ public void subscribe(CoreSubscriber actual) { } catch (RejectedExecutionException ree) { if(r.cancel != OperatorDisposables.DISPOSED) { - actual.onError(Operators.onRejectedExecution(ree, r, null, null)); + actual.onError(Operators.onRejectedExecution(ree, r, null, null, + actual.currentContext())); } } } @@ -110,7 +111,7 @@ public void run() { } } catch (Throwable t){ - actual.onError(Operators.onOperatorError(t)); + actual.onError(Operators.onOperatorError(t, actual.currentContext())); } } else { actual.onError(Exceptions.failWithOverflow("Could not emit value due to lack of requests")); diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoDelayElement.java b/reactor-core/src/main/java/reactor/core/publisher/MonoDelayElement.java index 9e8a491c6e..761dcd17ee 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoDelayElement.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoDelayElement.java @@ -115,7 +115,8 @@ public void onNext(T t) { this.task = scheduler.schedule(() -> complete(t), delay, unit); } catch (RejectedExecutionException ree) { - throw Operators.onRejectedExecution(ree, this, null, t); + throw Operators.onRejectedExecution(ree, this, null, t, + actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoElementAt.java b/reactor-core/src/main/java/reactor/core/publisher/MonoElementAt.java index 770229c6a3..ebc67c598b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoElementAt.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoElementAt.java @@ -150,7 +150,7 @@ public void onComplete() { } else{ actual.onError(Operators.onOperatorError(new - IndexOutOfBoundsException())); + IndexOutOfBoundsException(), actual.currentContext())); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoError.java b/reactor-core/src/main/java/reactor/core/publisher/MonoError.java index a4c6bee22f..abafd9b357 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoError.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoError.java @@ -49,7 +49,7 @@ public T block() { @Override public void subscribe(CoreSubscriber actual) { - Operators.error(actual, Operators.onOperatorError(error)); + Operators.error(actual, Operators.onOperatorError(error, actual.currentContext())); } @Override diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoFirst.java b/reactor-core/src/main/java/reactor/core/publisher/MonoFirst.java index 53ac8ee183..348c123702 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoFirst.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoFirst.java @@ -77,7 +77,8 @@ public void subscribe(CoreSubscriber actual) { it = Objects.requireNonNull(iterable.iterator(), "The iterator returned is null"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, + actual.currentContext())); return; } @@ -89,7 +90,8 @@ public void subscribe(CoreSubscriber actual) { b = it.hasNext(); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, + actual.currentContext())); return; } @@ -104,7 +106,8 @@ public void subscribe(CoreSubscriber actual) { "The Publisher returned by the iterator is null"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, + actual.currentContext())); return; } @@ -130,7 +133,8 @@ public void subscribe(CoreSubscriber actual) { if (p == null) { Operators.error(actual, - Operators.onOperatorError(new NullPointerException("The single source Publisher is null"))); + Operators.onOperatorError(new NullPointerException("The single source Publisher is null"), + actual.currentContext())); } else { p.subscribe(actual); diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMap.java b/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMap.java index 71df80a41f..a8e21f3bab 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMap.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMap.java @@ -119,7 +119,8 @@ public void onNext(T t) { "The mapper returned a null Mono"); } catch (Throwable ex) { - actual.onError(Operators.onOperatorError(s, ex, t)); + actual.onError(Operators.onOperatorError(s, ex, t, + actual.currentContext())); return; } @@ -131,7 +132,8 @@ public void onNext(T t) { v = c.call(); } catch (Throwable ex) { - actual.onError(Operators.onOperatorError(s, ex, t)); + actual.onError(Operators.onOperatorError(s, ex, t, + actual.currentContext())); return; } @@ -148,7 +150,8 @@ public void onNext(T t) { m.subscribe(second); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(this, e, t)); + actual.onError(Operators.onOperatorError(this, e, t, + actual.currentContext())); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMapMany.java b/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMapMany.java index e395a339c9..be48079c1d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMapMany.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoFlatMapMany.java @@ -154,7 +154,8 @@ public void onNext(T t) { "The mapper returned a null Publisher."); } catch (Throwable ex) { - actual.onError(Operators.onOperatorError(this, ex, t)); + actual.onError(Operators.onOperatorError(this, ex, t, + actual.currentContext())); return; } @@ -165,7 +166,8 @@ public void onNext(T t) { v = ((Callable) p).call(); } catch (Throwable ex) { - actual.onError(Operators.onOperatorError(this, ex, t)); + actual.onError(Operators.onOperatorError(this, ex, t, + actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoFlattenIterable.java b/reactor-core/src/main/java/reactor/core/publisher/MonoFlattenIterable.java index 9b03faded3..2ef46df788 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoFlattenIterable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoFlattenIterable.java @@ -71,7 +71,8 @@ public void subscribe(CoreSubscriber actual) { v = ((Callable) source).call(); } catch (Throwable ex) { - Operators.error(actual, Operators.onOperatorError(ex)); + Operators.error(actual, Operators.onOperatorError(ex, + actual.currentContext())); return; } @@ -88,7 +89,8 @@ public void subscribe(CoreSubscriber actual) { it = iter.iterator(); } catch (Throwable ex) { - Operators.error(actual, Operators.onOperatorError(ex)); + Operators.error(actual, Operators.onOperatorError(ex, + actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreThen.java b/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreThen.java index cc66bdd532..3615db7a85 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreThen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoIgnoreThen.java @@ -130,7 +130,8 @@ void drain() { v = ((Callable)m).call(); } catch (Throwable ex) { - actual.onError(Operators.onOperatorError(ex)); + actual.onError(Operators.onOperatorError(ex, + actual.currentContext())); return; } @@ -154,7 +155,8 @@ void drain() { ((Callable)m).call(); } catch (Throwable ex) { - actual.onError(Operators.onOperatorError(ex)); + actual.onError(Operators.onOperatorError(ex, + actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoPeekTerminal.java b/reactor-core/src/main/java/reactor/core/publisher/MonoPeekTerminal.java index 5903478d55..05687e0716 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoPeekTerminal.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoPeekTerminal.java @@ -166,7 +166,8 @@ public void onNext(T t) { parent.onTerminateCall.accept(t, null); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, + actual.currentContext())); return; } } @@ -175,7 +176,8 @@ public void onNext(T t) { parent.onSuccessCall.accept(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, + actual.currentContext())); return; } } @@ -188,7 +190,8 @@ public void onNext(T t) { } catch (Throwable e) { //don't invoke error callback, see https://github.com/reactor/reactor-core/issues/270 - Operators.onErrorDropped(Operators.onOperatorError(s, e, t), + Operators.onErrorDropped(Operators.onOperatorError(s, e, t, + actual.currentContext()), actual.currentContext()); } } @@ -215,7 +218,7 @@ public boolean tryOnNext(T t) { parent.onTerminateCall.accept(t, null); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return false; } } @@ -224,7 +227,7 @@ public boolean tryOnNext(T t) { parent.onSuccessCall.accept(t); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e, t)); + onError(Operators.onOperatorError(s, e, t, actual.currentContext())); return false; } } @@ -237,7 +240,8 @@ public boolean tryOnNext(T t) { } catch (Throwable e) { //don't invoke error callback, see https://github.com/reactor/reactor-core/issues/270 - Operators.onErrorDropped(Operators.onOperatorError(s, e, t), + Operators.onErrorDropped(Operators.onOperatorError(s, e, t, + actual.currentContext()), actual.currentContext()); } } @@ -258,7 +262,7 @@ public void onError(Throwable t) { parent.onTerminateCall.accept(null, t); } catch (Throwable e) { - t = Operators.onOperatorError(null, e, t); + t = Operators.onOperatorError(null, e, t, actual.currentContext()); } } @@ -277,7 +281,8 @@ public void onError(Throwable t) { } catch (Throwable e) { //don't invoke error callback, see https://github.com/reactor/reactor-core/issues/270 - Operators.onErrorDropped(Operators.onOperatorError(e), + Operators.onErrorDropped(Operators.onOperatorError(e, + actual.currentContext()), actual.currentContext()); } } @@ -294,7 +299,7 @@ public void onComplete() { parent.onTerminateCall.accept(null, null); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e)); + onError(Operators.onOperatorError(s, e, actual.currentContext())); return; } } @@ -303,7 +308,7 @@ public void onComplete() { parent.onSuccessCall.accept(null); } catch (Throwable e) { - onError(Operators.onOperatorError(s, e)); + onError(Operators.onOperatorError(s, e, actual.currentContext())); return; } } @@ -318,7 +323,8 @@ public void onComplete() { } catch (Throwable e) { //don't invoke error callback, see https://github.com/reactor/reactor-core/issues/270 - Operators.onErrorDropped(Operators.onOperatorError(e), + Operators.onErrorDropped(Operators.onOperatorError(e, + actual.currentContext()), actual.currentContext()); } } @@ -341,7 +347,8 @@ public T poll() { parent.onTerminateCall.accept(v, null); } catch (Throwable e) { - throw Exceptions.propagate(Operators.onOperatorError(s, e, v)); + throw Exceptions.propagate(Operators.onOperatorError(s, e, v, + actual.currentContext())); } } if (parent.onSuccessCall != null) { @@ -349,7 +356,8 @@ public T poll() { parent.onSuccessCall.accept(v); } catch (Throwable e) { - throw Exceptions.propagate(Operators.onOperatorError(s, e, v)); + throw Exceptions.propagate(Operators.onOperatorError(s, e, v, + actual.currentContext())); } } if (parent.onAfterTerminateCall != null) { @@ -357,7 +365,8 @@ public T poll() { parent.onAfterTerminateCall.accept(v, null); } catch (Throwable t) { - Operators.onErrorDropped(Operators.onOperatorError(t), + Operators.onErrorDropped(Operators.onOperatorError(t, + actual.currentContext()), actual.currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoPublishMulticast.java b/reactor-core/src/main/java/reactor/core/publisher/MonoPublishMulticast.java index 74debff72c..685cb119b4 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoPublishMulticast.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoPublishMulticast.java @@ -57,7 +57,7 @@ public void subscribe(CoreSubscriber actual) { "The transform returned a null Mono"); } catch (Throwable ex) { - Operators.error(actual, Operators.onOperatorError(ex)); + Operators.error(actual, Operators.onOperatorError(ex, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoPublishOn.java b/reactor-core/src/main/java/reactor/core/publisher/MonoPublishOn.java index cd75cb79be..aa9fffcfaf 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoPublishOn.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoPublishOn.java @@ -136,7 +136,7 @@ void trySchedule( } catch (RejectedExecutionException ree) { actual.onError(Operators.onRejectedExecution(ree, subscription, - suppressed, dataSignal)); + suppressed, dataSignal, actual.currentContext())); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoReduce.java b/reactor-core/src/main/java/reactor/core/publisher/MonoReduce.java index 7f9ea9f369..f1b0f36a91 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoReduce.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoReduce.java @@ -98,7 +98,8 @@ public void onNext(T t) { catch (Throwable ex) { result = null; done = true; - actual.onError(Operators.onOperatorError(s, ex, t)); + actual.onError(Operators.onOperatorError(s, ex, t, + actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoReduceSeed.java b/reactor-core/src/main/java/reactor/core/publisher/MonoReduceSeed.java index 88a5d9a17e..98395668ae 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoReduceSeed.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoReduceSeed.java @@ -58,7 +58,7 @@ public void subscribe(CoreSubscriber actual) { "The initial value supplied is null"); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -122,7 +122,7 @@ public void onNext(T t) { } catch (Throwable e) { - onError(Operators.onOperatorError(this, e, t)); + onError(Operators.onOperatorError(this, e, t, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoRepeatWhen.java b/reactor-core/src/main/java/reactor/core/publisher/MonoRepeatWhen.java index 42332189c6..1f0d34ef70 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoRepeatWhen.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoRepeatWhen.java @@ -69,7 +69,7 @@ public void subscribe(CoreSubscriber actual) { "The whenSourceFactory returned a null Publisher"); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(e)); + actual.onError(Operators.onOperatorError(e, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoRunnable.java b/reactor-core/src/main/java/reactor/core/publisher/MonoRunnable.java index 15797f79ac..b874f2c054 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoRunnable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoRunnable.java @@ -39,7 +39,7 @@ public void subscribe(CoreSubscriber actual) { try { run.run(); } catch (Throwable ex) { - Operators.error(actual, Operators.onOperatorError(ex)); + Operators.error(actual, Operators.onOperatorError(ex, actual.currentContext())); return; } Operators.complete(actual); diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSequenceEqual.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSequenceEqual.java index 5e5c9ffde8..bb35ad7875 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSequenceEqual.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSequenceEqual.java @@ -240,7 +240,8 @@ void drain() { Exceptions.throwIfFatal(ex); cancel(s1, q1, s2, q2); - actual.onError(Operators.onOperatorError(ex)); + actual.onError(Operators.onOperatorError(ex, + actual.currentContext())); return; } @@ -328,7 +329,8 @@ public void onSubscribe(Subscription s) { public void onNext(T t) { if (!queue.offer(t)) { onError(Operators.onOperatorError(cachedSubscription, Exceptions - .failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t)); + .failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t, + currentContext())); return; } parent.drain(); diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSingle.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSingle.java index d3c0d16554..b6aae1526d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSingle.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSingle.java @@ -162,7 +162,8 @@ public void onComplete() { } else { actual.onError(Operators.onOperatorError(this, - new NoSuchElementException("Source was empty"))); + new NoSuchElementException("Source was empty"), + actual.currentContext())); } } else if (c == 1) { diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoStreamCollector.java b/reactor-core/src/main/java/reactor/core/publisher/MonoStreamCollector.java index 85b1a14bc5..f8ecf67f8a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoStreamCollector.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoStreamCollector.java @@ -62,7 +62,7 @@ public void subscribe(CoreSubscriber actual) { finisher = collector.finisher(); } catch (Throwable ex) { - Operators.error(actual, Operators.onOperatorError(ex)); + Operators.error(actual, Operators.onOperatorError(ex, actual.currentContext())); return; } @@ -125,7 +125,7 @@ public void onNext(T t) { accumulator.accept(container, t); } catch (Throwable ex) { - onError(Operators.onOperatorError(s, ex, t)); + onError(Operators.onOperatorError(s, ex, t, actual.currentContext())); } } @@ -156,7 +156,7 @@ public void onComplete() { r = finisher.apply(a); } catch (Throwable ex) { - actual.onError(Operators.onOperatorError(ex)); + actual.onError(Operators.onOperatorError(ex, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOn.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOn.java index b756120a81..98d666a89a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOn.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOn.java @@ -56,7 +56,8 @@ public void subscribe(CoreSubscriber actual) { } catch (RejectedExecutionException ree) { if (parent.s != Operators.cancelledSubscription()) { - actual.onError(Operators.onRejectedExecution(ree, parent, null, null)); + actual.onError(Operators.onRejectedExecution(ree, parent, null, null, + actual.currentContext())); } } } @@ -168,7 +169,8 @@ void trySchedule(long n, Subscription s){ } catch (RejectedExecutionException ree) { if (!worker.isDisposed()) { - actual.onError(Operators.onRejectedExecution(ree, this, null, null)); + actual.onError(Operators.onRejectedExecution(ree, this, null, null, + actual.currentContext())); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOnCallable.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOnCallable.java index aa5dc9bc32..722a1f0b5e 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOnCallable.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOnCallable.java @@ -21,7 +21,6 @@ import java.util.concurrent.RejectedExecutionException; import reactor.core.CoreSubscriber; -import reactor.core.Disposable; import reactor.core.Fuseable; import reactor.core.scheduler.Scheduler; @@ -53,7 +52,7 @@ public void subscribe(CoreSubscriber actual) { } catch (RejectedExecutionException ree) { if(parent.state != FluxSubscribeOnCallable.CallableSubscribeOnSubscription.HAS_CANCELLED) { - actual.onError(Operators.onRejectedExecution(ree)); + actual.onError(Operators.onRejectedExecution(ree, actual.currentContext())); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOnValue.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOnValue.java index 19c136dab4..68478b711a 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOnValue.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSubscribeOnValue.java @@ -52,7 +52,8 @@ public void subscribe(CoreSubscriber actual) { } catch (RejectedExecutionException ree) { if (parent.future != OperatorDisposables.DISPOSED) { - actual.onError(Operators.onRejectedExecution(ree)); + actual.onError(Operators.onRejectedExecution(ree, + actual.currentContext())); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSubscriberContext.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSubscriberContext.java index 1c30d4a649..c3e0de1c42 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSubscriberContext.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSubscriberContext.java @@ -40,7 +40,7 @@ public void subscribe(CoreSubscriber actual) { c = doOnContext.apply(actual.currentContext()); } catch (Throwable t) { - Operators.error(actual, Operators.onOperatorError(t)); + Operators.error(actual, Operators.onOperatorError(t, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoSupplier.java b/reactor-core/src/main/java/reactor/core/publisher/MonoSupplier.java index e709261813..2416f4d161 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoSupplier.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoSupplier.java @@ -57,7 +57,7 @@ public void subscribe(CoreSubscriber actual) { "The supplier source returned null"); } catch (Throwable e) { - actual.onError(Operators.onOperatorError(e)); + actual.onError(Operators.onOperatorError(e, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoTakeLastOne.java b/reactor-core/src/main/java/reactor/core/publisher/MonoTakeLastOne.java index 5e3c6ee114..796a0017b6 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoTakeLastOne.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoTakeLastOne.java @@ -98,7 +98,8 @@ public void onComplete() { } else { actual.onError(Operators.onOperatorError(new NoSuchElementException( - "Flux#last() didn't observe any " + "onNext signal"))); + "Flux#last() didn't observe any " + "onNext signal"), + actual.currentContext())); } } else { diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoToCompletableFuture.java b/reactor-core/src/main/java/reactor/core/publisher/MonoToCompletableFuture.java index 21bad8915a..33bec9276b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoToCompletableFuture.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoToCompletableFuture.java @@ -58,7 +58,7 @@ public void onNext(T t) { s.cancel(); } else { - Operators.onNextDropped(t); + Operators.onNextDropped(t, currentContext()); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoUsing.java b/reactor-core/src/main/java/reactor/core/publisher/MonoUsing.java index 91ccc237b2..dc93b0b72f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoUsing.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoUsing.java @@ -70,7 +70,7 @@ public void subscribe(CoreSubscriber actual) { resource = resourceSupplier.call(); } catch (Throwable e) { - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } @@ -86,11 +86,11 @@ public void subscribe(CoreSubscriber actual) { resourceCleanup.accept(resource); } catch (Throwable ex) { - ex.addSuppressed(Operators.onOperatorError(e)); + ex.addSuppressed(Operators.onOperatorError(e, actual.currentContext())); e = ex; } - Operators.error(actual, Operators.onOperatorError(e)); + Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoZip.java b/reactor-core/src/main/java/reactor/core/publisher/MonoZip.java index 865f6081eb..0fd0dd4529 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoZip.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoZip.java @@ -240,7 +240,8 @@ void signal() { "zipper produced a null value"); } catch (Throwable t) { - actual.onError(Operators.onOperatorError(null, t, o)); + actual.onError(Operators.onOperatorError(null, t, o, + actual.currentContext())); return; } complete(r); diff --git a/reactor-core/src/main/java/reactor/core/publisher/Operators.java b/reactor-core/src/main/java/reactor/core/publisher/Operators.java index 5d4c9101be..bab7100763 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/Operators.java +++ b/reactor-core/src/main/java/reactor/core/publisher/Operators.java @@ -334,11 +334,12 @@ else if (log.isDebugEnabled()) { * {@link Exceptions#throwIfFatal(Throwable)}. * * @param error the callback or operator error + * @param context a context that might hold a local error consumer * @return mapped {@link Throwable} * */ - public static Throwable onOperatorError(Throwable error) { - return onOperatorError(null, error, null); + public static Throwable onOperatorError(Throwable error, Context context) { + return onOperatorError(null, error, context); } /** @@ -349,11 +350,14 @@ public static Throwable onOperatorError(Throwable error) { * * @param subscription the linked operator parent {@link Subscription} * @param error the callback or operator error + * @param context a context that might hold a local error consumer * @return mapped {@link Throwable} * */ - public static Throwable onOperatorError(@Nullable Subscription subscription, Throwable error) { - return onOperatorError(subscription, error, null); + public static Throwable onOperatorError(@Nullable Subscription subscription, + Throwable error, + Context context) { + return onOperatorError(subscription, error, null, context); } /** @@ -367,12 +371,13 @@ public static Throwable onOperatorError(@Nullable Subscription subscription, Thr * @param subscription the linked operator parent {@link Subscription} * @param error the callback or operator error * @param dataSignal the value (onNext or onError) signal processed during failure + * @param context a context that might hold a local error consumer * @return mapped {@link Throwable} * */ public static Throwable onOperatorError(@Nullable Subscription subscription, Throwable error, - @Nullable Object dataSignal) { + @Nullable Object dataSignal, Context context) { Exceptions.throwIfFatal(error); if(subscription != null) { @@ -402,11 +407,14 @@ public static Throwable onOperatorError(@Nullable Subscription subscription, * {@link reactor.core.scheduler.Scheduler}, notably when it was already disposed. *

    * Wrapping is done by calling both {@link Exceptions#bubble(Throwable)} and - * {@link #onOperatorError(Subscription, Throwable, Object)}. + * {@link #onOperatorError(Subscription, Throwable, Object, Context)}. + * + * @param original the original execution error + * @param context a context that might hold a local error consumer * */ - public static RuntimeException onRejectedExecution(Throwable original) { - return onRejectedExecution(original, null, null, null); + public static RuntimeException onRejectedExecution(Throwable original, Context context) { + return onRejectedExecution(original, null, null, null, context); } /** @@ -415,26 +423,30 @@ public static RuntimeException onRejectedExecution(Throwable original) { * {@link reactor.core.scheduler.Scheduler}, notably when it was already disposed. *

    * Wrapping is done by calling both {@link Exceptions#bubble(Throwable)} and - * {@link #onOperatorError(Subscription, Throwable, Object)} (with the passed + * {@link #onOperatorError(Subscription, Throwable, Object, Context)} (with the passed * {@link Subscription}). * + * @param original the original execution error * @param subscription the subscription to pass to onOperatorError. * @param suppressed a Throwable to be suppressed by the {@link RejectedExecutionException} (or null if not relevant) - * @param dataSignal a value to be passed to {@link #onOperatorError(Subscription, Throwable, Object)} (or null if not relevant) + * @param dataSignal a value to be passed to {@link #onOperatorError(Subscription, Throwable, Object, Context)} (or null if not relevant) + * @param context a context that might hold a local error consumer */ public static RuntimeException onRejectedExecution(Throwable original, @Nullable Subscription subscription, @Nullable Throwable suppressed, - @Nullable Object dataSignal) { + @Nullable Object dataSignal, Context context) { //FIXME only create REE if original is REE singleton OR there's suppressed OR there's Throwable dataSignal RejectedExecutionException ree = Exceptions.failWithRejected(original); if (suppressed != null) { ree.addSuppressed(suppressed); } if (dataSignal != null) { - return Exceptions.propagate(Operators.onOperatorError(subscription, ree, dataSignal)); + return Exceptions.propagate(Operators.onOperatorError(subscription, ree, dataSignal, + Context.empty())); } - return Exceptions.propagate(Operators.onOperatorError(subscription, ree)); + return Exceptions.propagate(Operators.onOperatorError(subscription, ree, + Context.empty())); } /** diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelCollect.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelCollect.java index 7b5afd9f08..a91922f436 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelCollect.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelCollect.java @@ -81,7 +81,8 @@ public void subscribe(CoreSubscriber[] subscribers) { "The initialSupplier returned a null value"); } catch (Throwable ex) { - reportError(subscribers, Operators.onOperatorError(ex)); + reportError(subscribers, Operators.onOperatorError(ex, + subscribers[i].currentContext())); return; } @@ -145,7 +146,7 @@ public void onNext(T t) { collector.accept(collection, t); } catch (Throwable ex) { - onError(Operators.onOperatorError(this, ex, t)); + onError(Operators.onOperatorError(this, ex, t, actual.currentContext())); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeReduce.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeReduce.java index 4fa03fe6d2..38d0dd25f6 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeReduce.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeReduce.java @@ -176,7 +176,8 @@ void innerComplete(@Nullable T value) { sp.second), "The reducer returned a null value"); } catch (Throwable ex) { - innerError(Operators.onOperatorError(this, ex)); + innerError(Operators.onOperatorError(this, ex, + actual.currentContext())); return; } } @@ -252,7 +253,7 @@ public void onSubscribe(Subscription s) { @Override public void onNext(T t) { if (done) { - Operators.onNextDropped(t, parent.currentContext()); + Operators.onNextDropped(t, currentContext()); return; } T v = value; @@ -266,7 +267,7 @@ public void onNext(T t) { v = Objects.requireNonNull(reducer.apply(v, t), "The reducer returned a null value"); } catch (Throwable ex) { - onError(Operators.onOperatorError(s, ex, t)); + onError(Operators.onOperatorError(s, ex, t, currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSequential.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSequential.java index 0c1bb5959a..b75986b00d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSequential.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelMergeSequential.java @@ -179,7 +179,8 @@ void onNext(MergeSequentialInner inner, T value) { Queue q = inner.getQueue(queueSupplier); if(!q.offer(value)){ - onError(Operators.onOperatorError(this, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), value)); + onError(Operators.onOperatorError(this, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), value, + actual.currentContext())); return; } } @@ -190,7 +191,8 @@ void onNext(MergeSequentialInner inner, T value) { Queue q = inner.getQueue(queueSupplier); if(!q.offer(value)){ - onError(Operators.onOperatorError(this, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), value)); + onError(Operators.onOperatorError(this, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), value, + actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelReduceSeed.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelReduceSeed.java index 316aac576c..e8551aba86 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelReduceSeed.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelReduceSeed.java @@ -82,7 +82,8 @@ public void subscribe(CoreSubscriber[] subscribers) { "The initialSupplier returned a null value"); } catch (Throwable ex) { - reportError(subscribers, Operators.onOperatorError(ex)); + reportError(subscribers, Operators.onOperatorError(ex, + subscribers[i].currentContext())); return; } parents[i] = @@ -147,7 +148,7 @@ public void onNext(T t) { v = Objects.requireNonNull(reducer.apply(accumulator, t), "The reducer returned a null value"); } catch (Throwable ex) { - onError(Operators.onOperatorError(this, ex, t)); + onError(Operators.onOperatorError(this, ex, t, actual.currentContext())); return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/ParallelSource.java b/reactor-core/src/main/java/reactor/core/publisher/ParallelSource.java index b4624b216d..1c57285e06 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ParallelSource.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ParallelSource.java @@ -226,7 +226,7 @@ public void onNext(T t) { } if (sourceMode == Fuseable.NONE) { if (!queue.offer(t)) { - onError(Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t)); + onError(Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t, currentContext())); return; } } @@ -268,7 +268,7 @@ void drainAsync() { int missed = 1; Queue q = queue; - Subscriber[] a = this.subscribers; + CoreSubscriber[] a = this.subscribers; AtomicLongArray r = this.requests; long[] e = this.emissions; int n = e.length; @@ -319,7 +319,7 @@ void drainAsync() { try { v = q.poll(); } catch (Throwable ex) { - ex = Operators.onOperatorError(s, ex); + ex = Operators.onOperatorError(s, ex, a[idx].currentContext()); for (Subscriber s : a) { s.onError(ex); } @@ -372,7 +372,7 @@ void drainSync() { int missed = 1; Queue q = queue; - Subscriber[] a = this.subscribers; + CoreSubscriber[] a = this.subscribers; AtomicLongArray r = this.requests; long[] e = this.emissions; int n = e.length; @@ -388,19 +388,7 @@ void drainSync() { return; } - boolean empty; - - try { - empty = q.isEmpty(); - } catch (Throwable ex) { - ex = Operators.onOperatorError(s, ex); - for (Subscriber s : a) { - s.onError(ex); - } - return; - } - - if (empty) { + if (q.isEmpty()) { for (Subscriber s : a) { s.onComplete(); } @@ -416,7 +404,7 @@ void drainSync() { try { v = q.poll(); } catch (Throwable ex) { - ex = Operators.onOperatorError(s, ex); + ex = Operators.onOperatorError(s, ex, a[idx].currentContext()); for (Subscriber s : a) { s.onError(ex); } diff --git a/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java index 94f1debcd5..e83f107872 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java @@ -423,7 +423,7 @@ public int getPrefetch() { public void onNext(T t) { FluxReplay.ReplayBuffer b = buffer; if (b.isDone()) { - Operators.onNextDropped(t); + Operators.onNextDropped(t, currentContext()); } else { b.add(t); diff --git a/reactor-core/src/main/java/reactor/core/publisher/UnicastProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/UnicastProcessor.java index 5dae84de63..0e5051ad5b 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/UnicastProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/UnicastProcessor.java @@ -30,6 +30,7 @@ import reactor.core.Exceptions; import reactor.core.Fuseable; import reactor.util.concurrent.Queues; +import reactor.util.context.Context; /** * A Processor implementation that takes a custom queue and allows @@ -304,16 +305,22 @@ public int getPrefetch() { return Integer.MAX_VALUE; } + @Override + public Context currentContext() { + CoreSubscriber actual = this.actual; + return actual != null ? actual.currentContext() : Context.empty(); + } + @Override public void onNext(T t) { if (done || cancelled) { - Operators.onNextDropped(t, actual.currentContext()); + Operators.onNextDropped(t, currentContext()); return; } if (!queue.offer(t)) { Throwable ex = Operators.onOperatorError(null, - Exceptions.failWithOverflow(), t); + Exceptions.failWithOverflow(), t, currentContext()); if(onOverflow != null) { try { onOverflow.accept(t); @@ -323,7 +330,7 @@ public void onNext(T t) { ex.initCause(e); } } - onError(Operators.onOperatorError(null, ex, t)); + onError(Operators.onOperatorError(null, ex, t, currentContext())); return; } drain(); @@ -332,7 +339,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done || cancelled) { - Operators.onErrorDropped(t, actual.currentContext()); + Operators.onErrorDropped(t, currentContext()); return; } diff --git a/reactor-core/src/test/java/reactor/core/publisher/HooksTest.java b/reactor-core/src/test/java/reactor/core/publisher/HooksTest.java index f90865cccc..0d145588a6 100644 --- a/reactor-core/src/test/java/reactor/core/publisher/HooksTest.java +++ b/reactor-core/src/test/java/reactor/core/publisher/HooksTest.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -41,6 +41,7 @@ import reactor.test.StepVerifier; import reactor.test.publisher.TestPublisher; import reactor.test.subscriber.AssertSubscriber; +import reactor.util.context.Context; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -534,7 +535,7 @@ public void errorHooks() throws Exception { throw new TestException("errorDrop"); }); - Throwable w = Operators.onOperatorError(null, new Exception(), "hello"); + Throwable w = Operators.onOperatorError(null, new Exception(), "hello", Context.empty()); Assert.assertTrue(w instanceof TestException); Assert.assertTrue(w.getMessage() @@ -599,7 +600,7 @@ public void accumulatingHooks() throws Exception { return error; }); - Operators.onOperatorError(null, null, "foo"); + Operators.onOperatorError(null, null, "foo", Context.empty()); assertThat(ref.get()).isEqualTo("foobar"); diff --git a/reactor-test/src/test/java/reactor/test/StepVerifierAssertionsTests.java b/reactor-test/src/test/java/reactor/test/StepVerifierAssertionsTests.java index e579333143..fe2d71977b 100644 --- a/reactor-test/src/test/java/reactor/test/StepVerifierAssertionsTests.java +++ b/reactor-test/src/test/java/reactor/test/StepVerifierAssertionsTests.java @@ -21,6 +21,7 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.publisher.Operators; +import reactor.util.context.Context; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -423,8 +424,8 @@ public void assertOperatorErrorsFailureWrongCount() { StepVerifier.create(Flux.from(s -> { s.onSubscribe(Operators.emptySubscription()); s.onError(err1); - Operators.onOperatorError(err2); - Operators.onOperatorError(err3); + Operators.onOperatorError(err2, Context.empty()); + Operators.onOperatorError(err3, Context.empty()); }).buffer(1)) .expectError() .verifyThenAssertThat() @@ -446,8 +447,8 @@ public void assertOperatorErrorsNotSatisfying() { StepVerifier.create(Flux.from(s -> { s.onSubscribe(Operators.emptySubscription()); s.onError(err1); - Operators.onOperatorError(err2); - Operators.onOperatorError(err3); + Operators.onOperatorError(err2, Context.empty()); + Operators.onOperatorError(err3, Context.empty()); }).buffer(1)) .expectError() .verifyThenAssertThat() @@ -470,8 +471,8 @@ public void assertOperatorErrorsNotMatching() { StepVerifier.create(Flux.from(s -> { s.onSubscribe(Operators.emptySubscription()); s.onError(err1); - Operators.onOperatorError(err2); - Operators.onOperatorError(err3); + Operators.onOperatorError(err2, Context.empty()); + Operators.onOperatorError(err3, Context.empty()); }).buffer(1)) .expectError() .verifyThenAssertThat() @@ -564,7 +565,7 @@ public void assertOperationErrorShortcutTestTupleContainsError() { try { StepVerifier.create(Flux.from(f -> { f.onSubscribe(Operators.emptySubscription()); - Operators.onOperatorError(null, null, "foo"); + Operators.onOperatorError(null, null, "foo", Context.empty()); f.onComplete(); })) .expectComplete() From b1237b851d9bc41ea884674929cd4c0c8dce61c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Basl=C3=A9?= Date: Fri, 1 Sep 2017 15:04:20 +0200 Subject: [PATCH 3/5] remaining calls to drops without a context either use explicit empty... or are "multicast" cases mark as such for future refactor --- .../core/publisher/EmitterProcessor.java | 2 +- .../reactor/core/publisher/FluxPublish.java | 6 ++--- .../core/publisher/LambdaMonoSubscriber.java | 11 +++++---- .../core/publisher/LambdaSubscriber.java | 4 +++- .../reactor/core/publisher/MonoCacheTime.java | 4 ++-- .../reactor/core/publisher/MonoProcessor.java | 9 +++---- .../reactor/core/publisher/Operators.java | 24 ++++++++++++++----- .../core/publisher/ReplayProcessor.java | 2 +- .../core/publisher/StrictSubscriber.java | 3 ++- .../reactor/core/publisher/HooksTest.java | 8 +++---- .../publisher/OperatorDisposablesTest.java | 4 +++- 11 files changed, 48 insertions(+), 29 deletions(-) diff --git a/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java index c190be1b34..7131d7159c 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/EmitterProcessor.java @@ -277,7 +277,7 @@ public void onError(Throwable t) { drain(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDroppedMulticast(t); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/FluxPublish.java b/reactor-core/src/main/java/reactor/core/publisher/FluxPublish.java index 5d1db15fa6..3c107d2578 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/FluxPublish.java +++ b/reactor-core/src/main/java/reactor/core/publisher/FluxPublish.java @@ -255,7 +255,7 @@ public void onNext(T t) { Throwable ex = Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t, currentContext()); if (!Exceptions.addThrowable(ERROR, this, ex)) { - Operators.onErrorDropped(ex); + Operators.onErrorDroppedMulticast(ex); return; } done = true; @@ -266,7 +266,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (done) { - Operators.onErrorDropped(t); + Operators.onErrorDroppedMulticast(t); return; } if (Exceptions.addThrowable(ERROR, this, t)) { @@ -274,7 +274,7 @@ public void onError(Throwable t) { drain(); } else { - Operators.onErrorDropped(t); + Operators.onErrorDroppedMulticast(t); } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/LambdaMonoSubscriber.java b/reactor-core/src/main/java/reactor/core/publisher/LambdaMonoSubscriber.java index 1e4646f294..25febc4a75 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/LambdaMonoSubscriber.java +++ b/reactor-core/src/main/java/reactor/core/publisher/LambdaMonoSubscriber.java @@ -24,6 +24,7 @@ import org.reactivestreams.Subscription; import reactor.core.Disposable; import reactor.core.Exceptions; +import reactor.util.context.Context; /** * An unbounded Java Lambda adapter to {@link Subscriber}, targetted at {@link Mono}. @@ -100,7 +101,7 @@ public final void onComplete() { completeConsumer.run(); } catch (Throwable t) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, Context.empty()); } } } @@ -109,7 +110,7 @@ public final void onComplete() { public final void onError(Throwable t) { Subscription s = S.getAndSet(this, Operators.cancelledSubscription()); if (s == Operators.cancelledSubscription()) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, Context.empty()); return; } doError(t); @@ -128,7 +129,7 @@ void doError(Throwable t) { public final void onNext(T x) { Subscription s = S.getAndSet(this, Operators.cancelledSubscription()); if (s == Operators.cancelledSubscription()) { - Operators.onNextDropped(x, currentContext()); + Operators.onNextDropped(x, Context.empty()); return; } if (consumer != null) { @@ -136,7 +137,7 @@ public final void onNext(T x) { consumer.accept(x); } catch (Throwable t) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, Context.empty()); return; } } @@ -145,7 +146,7 @@ public final void onNext(T x) { completeConsumer.run(); } catch (Throwable t) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, Context.empty()); } } } diff --git a/reactor-core/src/main/java/reactor/core/publisher/LambdaSubscriber.java b/reactor-core/src/main/java/reactor/core/publisher/LambdaSubscriber.java index ff3eaa4e1d..d069d4664f 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/LambdaSubscriber.java +++ b/reactor-core/src/main/java/reactor/core/publisher/LambdaSubscriber.java @@ -23,6 +23,8 @@ import org.reactivestreams.Subscription; import reactor.core.Disposable; import reactor.core.Exceptions; +import reactor.util.context.Context; + import javax.annotation.Nullable; /** @@ -110,7 +112,7 @@ public final void onComplete() { public final void onError(Throwable t) { Subscription s = S.getAndSet(this, Operators.cancelledSubscription()); if (s == Operators.cancelledSubscription()) { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, Context.empty()); return; } if (errorConsumer != null) { diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoCacheTime.java b/reactor-core/src/main/java/reactor/core/publisher/MonoCacheTime.java index 4353025cf1..5e657aea5d 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoCacheTime.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoCacheTime.java @@ -248,7 +248,7 @@ else if (signal.isOnError()) { @Override public void onNext(T t) { if (main.state != this) { - Operators.onNextDropped(t); + Operators.onNextDroppedMulticast(t); return; } signalCached(Signal.next(t)); @@ -257,7 +257,7 @@ public void onNext(T t) { @Override public void onError(Throwable t) { if (main.state != this) { - Operators.onErrorDropped(t); + Operators.onErrorDroppedMulticast(t); return; } signalCached(Signal.error(t)); diff --git a/reactor-core/src/main/java/reactor/core/publisher/MonoProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/MonoProcessor.java index 6c7b5c3558..6304d91422 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/MonoProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/MonoProcessor.java @@ -33,6 +33,7 @@ import reactor.core.Exceptions; import reactor.core.Scannable; import reactor.util.concurrent.WaitStrategy; +import reactor.util.context.Context; /** * A {@code MonoProcessor} is a {@link Mono} extension that implements stateful semantics. Multi-subscribe is allowed. @@ -275,7 +276,7 @@ public final void onError(Throwable cause) { Subscription s = subscription; if ((source != null && s == null) || this.error != null) { - Operators.onErrorDropped(cause); + Operators.onErrorDroppedMulticast(cause); return; } @@ -286,7 +287,7 @@ public final void onError(Throwable cause) { int state = this.state; for (; ; ) { if (state != STATE_READY && state != STATE_SUBSCRIBED && state != STATE_POST_SUBSCRIBED) { - Operators.onErrorDropped(cause); + Operators.onErrorDroppedMulticast(cause); return; } if (STATE.compareAndSet(this, state, STATE_ERROR)) { @@ -305,7 +306,7 @@ public final void onNext(O value) { Subscription s = subscription; if (value != null && ((source != null && s == null) || this.value != null)) { - Operators.onNextDropped(value); + Operators.onNextDroppedMulticast(value); return; } subscription = null; @@ -328,7 +329,7 @@ public final void onNext(O value) { for (; ; ) { if (state != STATE_READY && state != STATE_SUBSCRIBED && state != STATE_POST_SUBSCRIBED) { if(value != null) { - Operators.onNextDropped(value); + Operators.onNextDroppedMulticast(value); } return; } diff --git a/reactor-core/src/main/java/reactor/core/publisher/Operators.java b/reactor-core/src/main/java/reactor/core/publisher/Operators.java index bab7100763..19ece68ea4 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/Operators.java +++ b/reactor-core/src/main/java/reactor/core/publisher/Operators.java @@ -268,12 +268,15 @@ public static long multiplyCap(long a, long b) { } /** - * An unexpected exception is about to be dropped. + * An unexpected exception is about to be dropped from an operator that has multiple + * subscribers (and thus potentially multiple Context with local onErrorDropped handlers). * * @param e the dropped exception * @see #onErrorDropped(Throwable, Context) */ - public static void onErrorDropped(Throwable e) { + public static void onErrorDroppedMulticast(Throwable e) { + //FIXME let this method go through multiple contexts and use their local handlers + //if at least one has no local handler, also call onErrorDropped(e, Context.empty()) onErrorDropped(e, Context.empty()); } @@ -284,6 +287,7 @@ public static void onErrorDropped(Throwable e) { * @param context a context that might hold a local error consumer */ public static void onErrorDropped(Throwable e, Context context) { + //FIXME check for hook in context first Consumer hook = Hooks.onErrorDroppedHook; if (hook == null) { throw Exceptions.bubble(e); @@ -292,7 +296,8 @@ public static void onErrorDropped(Throwable e, Context context) { } /** - * An unexpected event is about to be dropped. + * An unexpected event is about to be dropped from an operator that has multiple + * subscribers (and thus potentially multiple Context with local onNextDropped handlers). *

    * If no hook is registered for {@link Hooks#onNextDropped(Consumer)}, the dropped * element is just logged at DEBUG level. @@ -301,7 +306,9 @@ public static void onErrorDropped(Throwable e, Context context) { * @param t the dropped data * @see #onNextDropped(Object, Context) */ - public static void onNextDropped(T t) { + public static void onNextDroppedMulticast(T t) { + //FIXME let this method go through multiple contexts and use their local handlers + //if at least one has no local handler, also call onNextDropped(t, Context.empty()) onNextDropped(t, Context.empty()); } @@ -318,6 +325,7 @@ public static void onNextDropped(T t) { public static void onNextDropped(T t, Context context) { Objects.requireNonNull(t, "onNext"); Objects.requireNonNull(context, "context"); + //FIXME check for hook in context first Consumer hook = Hooks.onNextDroppedHook; if (hook != null) { hook.accept(t); @@ -385,6 +393,7 @@ public static Throwable onOperatorError(@Nullable Subscription subscription, } Throwable t = Exceptions.unwrap(error); + //FIXME check for hook in context first BiFunction hook = Hooks.onOperatorErrorHook; if (hook == null) { @@ -435,7 +444,8 @@ public static RuntimeException onRejectedExecution(Throwable original, Context c public static RuntimeException onRejectedExecution(Throwable original, @Nullable Subscription subscription, @Nullable Throwable suppressed, - @Nullable Object dataSignal, Context context) { + @Nullable Object dataSignal, + Context context) { //FIXME only create REE if original is REE singleton OR there's suppressed OR there's Throwable dataSignal RejectedExecutionException ree = Exceptions.failWithRejected(original); if (suppressed != null) { @@ -443,9 +453,11 @@ public static RuntimeException onRejectedExecution(Throwable original, } if (dataSignal != null) { return Exceptions.propagate(Operators.onOperatorError(subscription, ree, dataSignal, + //TODO shouldn't we use the passed Context here? Context.empty())); } return Exceptions.propagate(Operators.onOperatorError(subscription, ree, + //TODO shouldn't we use the passed Context here? Context.empty())); } @@ -1643,7 +1655,7 @@ public void onNext(Object o) { @Override public void onError(Throwable t) { - Operators.onErrorDropped(Exceptions.errorCallbackNotImplemented(t)); + Operators.onErrorDropped(Exceptions.errorCallbackNotImplemented(t), Context.empty()); } @Override diff --git a/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java b/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java index e83f107872..e4e2695415 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java +++ b/reactor-core/src/main/java/reactor/core/publisher/ReplayProcessor.java @@ -437,7 +437,7 @@ public void onNext(T t) { public void onError(Throwable t) { FluxReplay.ReplayBuffer b = buffer; if (b.isDone()) { - Operators.onErrorDropped(t); + Operators.onErrorDroppedMulticast(t); } else { b.onError(t); diff --git a/reactor-core/src/main/java/reactor/core/publisher/StrictSubscriber.java b/reactor-core/src/main/java/reactor/core/publisher/StrictSubscriber.java index 140ca50eb6..06d73729ee 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/StrictSubscriber.java +++ b/reactor-core/src/main/java/reactor/core/publisher/StrictSubscriber.java @@ -26,6 +26,7 @@ import reactor.core.CoreSubscriber; import reactor.core.Exceptions; import reactor.core.Scannable; +import reactor.util.context.Context; /** * Reactive Streams Commons safe exit @@ -106,7 +107,7 @@ public void onError(Throwable t) { } } else { - Operators.onErrorDropped(t); + Operators.onErrorDropped(t, Context.empty()); } } diff --git a/reactor-core/src/test/java/reactor/core/publisher/HooksTest.java b/reactor-core/src/test/java/reactor/core/publisher/HooksTest.java index 0d145588a6..e47f0f4244 100644 --- a/reactor-core/src/test/java/reactor/core/publisher/HooksTest.java +++ b/reactor-core/src/test/java/reactor/core/publisher/HooksTest.java @@ -542,7 +542,7 @@ public void errorHooks() throws Exception { .equals("hello")); try { - Operators.onNextDropped("hello"); + Operators.onNextDropped("hello", Context.empty()); Assert.fail(); } catch (Throwable t) { @@ -553,7 +553,7 @@ public void errorHooks() throws Exception { } try { - Operators.onErrorDropped(new Exception()); + Operators.onErrorDropped(new Exception(), Context.empty()); Assert.fail(); } catch (Throwable t) { @@ -573,7 +573,7 @@ public void accumulatingHooks() throws Exception { ref.set(ref.get()+"bar"); }); - Operators.onNextDropped("foo"); + Operators.onNextDropped("foo", Context.empty()); assertThat(ref.get()).isEqualTo("foobar"); @@ -584,7 +584,7 @@ public void accumulatingHooks() throws Exception { ref.set(ref.get()+"bar"); }); - Operators.onErrorDropped(new Exception("foo")); + Operators.onErrorDropped(new Exception("foo"), Context.empty()); assertThat(ref.get()).isEqualTo("foobar"); diff --git a/reactor-core/src/test/java/reactor/core/publisher/OperatorDisposablesTest.java b/reactor-core/src/test/java/reactor/core/publisher/OperatorDisposablesTest.java index 2c091f54d3..be0559be79 100644 --- a/reactor-core/src/test/java/reactor/core/publisher/OperatorDisposablesTest.java +++ b/reactor-core/src/test/java/reactor/core/publisher/OperatorDisposablesTest.java @@ -23,6 +23,7 @@ import reactor.core.Disposables; import reactor.core.scheduler.Schedulers; import reactor.test.RaceTestUtils; +import reactor.util.context.Context; import static org.assertj.core.api.Assertions.assertThat; @@ -61,7 +62,8 @@ public void validationNull() { Hooks.onErrorDropped(e -> assertThat(e).isInstanceOf(NullPointerException.class) .hasMessage("next is null")); try { - assertThat(OperatorDisposables.validate(null, null, Operators::onErrorDropped)).isFalse(); + assertThat(OperatorDisposables.validate(null, null, + e -> Operators.onErrorDropped(e, Context.empty()))).isFalse(); } finally { Hooks.resetOnErrorDropped(); } From df21ff976055ae0c145e99fcb7a2ea457a50db46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Basl=C3=A9?= Date: Mon, 4 Sep 2017 21:38:32 +0200 Subject: [PATCH 4/5] look for local hooks in Context for onErrorDropped/onNextDropped/onOperatorError/onRejectedExecution --- .../reactor/core/publisher/Operators.java | 53 +++++++++---- .../reactor/core/publisher/OperatorsTest.java | 79 +++++++++++++++++++ 2 files changed, 116 insertions(+), 16 deletions(-) diff --git a/reactor-core/src/main/java/reactor/core/publisher/Operators.java b/reactor-core/src/main/java/reactor/core/publisher/Operators.java index 19ece68ea4..4d0a20db49 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/Operators.java +++ b/reactor-core/src/main/java/reactor/core/publisher/Operators.java @@ -47,6 +47,24 @@ */ public abstract class Operators { + /** + * A key that can be used to store a sequence-specific {@link Hooks#onErrorDropped(Consumer)} + * hook in a {@link Context}, as a {@link Consumer Consumer<Throwable>}. + */ + public static final String KEY_ON_ERROR_DROPPED = "reactor.onErrorDropped.local"; + + /** + * A key that can be used to store a sequence-specific {@link Hooks#onNextDropped(Consumer)} + * hook in a {@link Context}, as a {@link Consumer Consumer<Object>}. + */ + public static final String KEY_ON_NEXT_DROPPED = "reactor.onNextDropped.local"; + + /** + * A key that can be used to store a sequence-specific {@link Hooks#onOperatorError(BiFunction)} + * hook in a {@link Context}, as a {@link BiFunction BiFunction<Throwable, Object, Throwable>}. + */ + public static final String KEY_ON_OPERATOR_ERROR = "reactor.onOperatorError.local"; + /** * Concurrent addition bound to Long.MAX_VALUE. Any concurrent write will "happen * before" this operation. @@ -275,7 +293,7 @@ public static long multiplyCap(long a, long b) { * @see #onErrorDropped(Throwable, Context) */ public static void onErrorDroppedMulticast(Throwable e) { - //FIXME let this method go through multiple contexts and use their local handlers + //TODO let this method go through multiple contexts and use their local handlers //if at least one has no local handler, also call onErrorDropped(e, Context.empty()) onErrorDropped(e, Context.empty()); } @@ -284,11 +302,13 @@ public static void onErrorDroppedMulticast(Throwable e) { * An unexpected exception is about to be dropped. * * @param e the dropped exception - * @param context a context that might hold a local error consumer + * @param context a context that might hold a local error consumer (see {@link #KEY_ON_ERROR_DROPPED}) */ public static void onErrorDropped(Throwable e, Context context) { - //FIXME check for hook in context first - Consumer hook = Hooks.onErrorDroppedHook; + Consumer hook = context.getOrDefault(KEY_ON_ERROR_DROPPED,null); + if (hook == null) { + hook = Hooks.onErrorDroppedHook; + } if (hook == null) { throw Exceptions.bubble(e); } @@ -307,7 +327,7 @@ public static void onErrorDropped(Throwable e, Context context) { * @see #onNextDropped(Object, Context) */ public static void onNextDroppedMulticast(T t) { - //FIXME let this method go through multiple contexts and use their local handlers + //TODO let this method go through multiple contexts and use their local handlers //if at least one has no local handler, also call onNextDropped(t, Context.empty()) onNextDropped(t, Context.empty()); } @@ -320,13 +340,15 @@ public static void onNextDroppedMulticast(T t) { * * @param the dropped value type * @param t the dropped data - * @param context a context that might hold a local error consumer + * @param context a context that might hold a local next consumer (see {@link #KEY_ON_NEXT_DROPPED}) */ public static void onNextDropped(T t, Context context) { Objects.requireNonNull(t, "onNext"); Objects.requireNonNull(context, "context"); - //FIXME check for hook in context first - Consumer hook = Hooks.onNextDroppedHook; + Consumer hook = context.getOrDefault(KEY_ON_NEXT_DROPPED, null); + if (hook == null) { + hook = Hooks.onNextDroppedHook; + } if (hook != null) { hook.accept(t); } @@ -393,9 +415,11 @@ public static Throwable onOperatorError(@Nullable Subscription subscription, } Throwable t = Exceptions.unwrap(error); - //FIXME check for hook in context first BiFunction hook = - Hooks.onOperatorErrorHook; + context.getOrDefault(KEY_ON_OPERATOR_ERROR, null); + if (hook == null) { + hook = Hooks.onOperatorErrorHook; + } if (hook == null) { if (dataSignal != null) { if (dataSignal != t && dataSignal instanceof Throwable) { @@ -452,13 +476,10 @@ public static RuntimeException onRejectedExecution(Throwable original, ree.addSuppressed(suppressed); } if (dataSignal != null) { - return Exceptions.propagate(Operators.onOperatorError(subscription, ree, dataSignal, - //TODO shouldn't we use the passed Context here? - Context.empty())); + return Exceptions.propagate(Operators.onOperatorError(subscription, ree, + dataSignal, context)); } - return Exceptions.propagate(Operators.onOperatorError(subscription, ree, - //TODO shouldn't we use the passed Context here? - Context.empty())); + return Exceptions.propagate(Operators.onOperatorError(subscription, ree, context)); } /** diff --git a/reactor-core/src/test/java/reactor/core/publisher/OperatorsTest.java b/reactor-core/src/test/java/reactor/core/publisher/OperatorsTest.java index 477f63ca1c..23e25664cd 100644 --- a/reactor-core/src/test/java/reactor/core/publisher/OperatorsTest.java +++ b/reactor-core/src/test/java/reactor/core/publisher/OperatorsTest.java @@ -16,8 +16,12 @@ package reactor.core.publisher; +import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLongFieldUpdater; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.BiFunction; +import java.util.function.Consumer; import org.assertj.core.api.Assertions; import org.junit.Test; @@ -33,6 +37,7 @@ import reactor.core.publisher.Operators.MultiSubscriptionSubscriber; import reactor.core.publisher.Operators.ScalarSubscription; import reactor.test.RaceTestUtils; +import reactor.util.context.Context; import static org.assertj.core.api.Assertions.assertThat; @@ -250,4 +255,78 @@ public void scanScalarSubscription() { Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); } + + @Test + public void onErrorDroppedLocal() { + AtomicReference hookState = new AtomicReference<>(); + Consumer localHook = hookState::set; + Context c = Context.of(Operators.KEY_ON_ERROR_DROPPED, localHook); + + Operators.onErrorDropped(new IllegalArgumentException("boom"), c); + + assertThat(hookState.get()).isInstanceOf(IllegalArgumentException.class) + .hasMessage("boom"); + } + + @Test + public void onNextDroppedLocal() { + AtomicReference hookState = new AtomicReference<>(); + Consumer localHook = hookState::set; + Context c = Context.of(Operators.KEY_ON_NEXT_DROPPED, localHook); + + Operators.onNextDropped("foo", c); + + assertThat(hookState.get()).isEqualTo("foo"); + } + + @Test + public void onOperatorErrorLocal() { + BiFunction localHook = (e, v) -> + new IllegalStateException("boom_" + v, e); + Context c = Context.of(Operators.KEY_ON_OPERATOR_ERROR, localHook); + + IllegalArgumentException failure = new IllegalArgumentException("foo"); + + final Throwable throwable = Operators.onOperatorError(null, failure, + "foo", c); + + assertThat(throwable).isInstanceOf(IllegalStateException.class) + .hasMessage("boom_foo") + .hasCause(failure); + } + + @Test + public void onRejectedExecutionWithoutDataSignalErrorLocal() { + BiFunction localHook = (e, v) -> + new IllegalStateException("boom_" + v, e); + Context c = Context.of(Operators.KEY_ON_OPERATOR_ERROR, localHook); + + IllegalArgumentException failure = new IllegalArgumentException("foo"); + final Throwable throwable = Operators.onRejectedExecution(failure, null, null, null, c); + + assertThat(throwable).isInstanceOf(IllegalStateException.class) + .hasMessage("boom_null") + .hasNoSuppressedExceptions(); + assertThat(throwable.getCause()).isInstanceOf(RejectedExecutionException.class) + .hasMessage("Scheduler unavailable") + .hasCause(failure); + } + + @Test + public void onRejectedExecutionWithDataSignalErrorLocal() { + BiFunction localHook = (e, v) -> + new IllegalStateException("boom_" + v, e); + Context c = Context.of(Operators.KEY_ON_OPERATOR_ERROR, localHook); + + IllegalArgumentException failure = new IllegalArgumentException("foo"); + final Throwable throwable = Operators.onRejectedExecution(failure, null, + null, "bar", c); + + assertThat(throwable).isInstanceOf(IllegalStateException.class) + .hasMessage("boom_bar") + .hasNoSuppressedExceptions(); + assertThat(throwable.getCause()).isInstanceOf(RejectedExecutionException.class) + .hasMessage("Scheduler unavailable") + .hasCause(failure); + } } From 25aef6cb6bfc986084fe2381c616e8d71194bc55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Basl=C3=A9?= Date: Tue, 5 Sep 2017 16:34:42 +0200 Subject: [PATCH 5/5] ability to local hook for Operators.onRejectedExecution this works by replacing the onOperatorError hook in the context passed when calling Operators.onOperatorError from onRejectedExecution (if there is a local hook for the REE-specific key). --- .../reactor/core/publisher/Operators.java | 12 +++++++++ .../reactor/core/publisher/OperatorsTest.java | 27 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/reactor-core/src/main/java/reactor/core/publisher/Operators.java b/reactor-core/src/main/java/reactor/core/publisher/Operators.java index 4d0a20db49..358cc822de 100644 --- a/reactor-core/src/main/java/reactor/core/publisher/Operators.java +++ b/reactor-core/src/main/java/reactor/core/publisher/Operators.java @@ -65,6 +65,13 @@ public abstract class Operators { */ public static final String KEY_ON_OPERATOR_ERROR = "reactor.onOperatorError.local"; + /** + * A key that can be used to store a sequence-specific {@link Hooks#onOperatorError(BiFunction)} + * hook THAT IS ONLY APPLIED TO Operators{@link #onRejectedExecution(Throwable, Context) onRejectedExecution} + * in a {@link Context}, as a {@link BiFunction BiFunction<Throwable, Object, Throwable>}. + */ + public static final String KEY_ON_REJECTED_EXECUTION = "reactor.onRejectedExecution.local"; + /** * Concurrent addition bound to Long.MAX_VALUE. Any concurrent write will "happen * before" this operation. @@ -470,6 +477,11 @@ public static RuntimeException onRejectedExecution(Throwable original, @Nullable Throwable suppressed, @Nullable Object dataSignal, Context context) { + //we "cheat" to apply the special key for onRejectedExecution in onOperatorError + if (context.hasKey(KEY_ON_REJECTED_EXECUTION)) { + context = context.put(KEY_ON_OPERATOR_ERROR, context.get(KEY_ON_REJECTED_EXECUTION)); + } + //FIXME only create REE if original is REE singleton OR there's suppressed OR there's Throwable dataSignal RejectedExecutionException ree = Exceptions.failWithRejected(original); if (suppressed != null) { diff --git a/reactor-core/src/test/java/reactor/core/publisher/OperatorsTest.java b/reactor-core/src/test/java/reactor/core/publisher/OperatorsTest.java index 23e25664cd..c767fd3cbb 100644 --- a/reactor-core/src/test/java/reactor/core/publisher/OperatorsTest.java +++ b/reactor-core/src/test/java/reactor/core/publisher/OperatorsTest.java @@ -296,7 +296,7 @@ public void onOperatorErrorLocal() { } @Test - public void onRejectedExecutionWithoutDataSignalErrorLocal() { + public void onRejectedExecutionWithoutDataSignalDelegatesToErrorLocal() { BiFunction localHook = (e, v) -> new IllegalStateException("boom_" + v, e); Context c = Context.of(Operators.KEY_ON_OPERATOR_ERROR, localHook); @@ -313,7 +313,7 @@ public void onRejectedExecutionWithoutDataSignalErrorLocal() { } @Test - public void onRejectedExecutionWithDataSignalErrorLocal() { + public void onRejectedExecutionWithDataSignalDelegatesToErrorLocal() { BiFunction localHook = (e, v) -> new IllegalStateException("boom_" + v, e); Context c = Context.of(Operators.KEY_ON_OPERATOR_ERROR, localHook); @@ -329,4 +329,27 @@ public void onRejectedExecutionWithDataSignalErrorLocal() { .hasMessage("Scheduler unavailable") .hasCause(failure); } + + @Test + public void onRejectedExecutionLocalTakesPrecedenceOverOnOperatorError() { + BiFunction localOperatorErrorHook = (e, v) -> + new IllegalStateException("boom_" + v, e); + + BiFunction localReeHook = (e, v) -> + new IllegalStateException("rejected_" + v, e); + Context c = Context.of( + Operators.KEY_ON_OPERATOR_ERROR, localOperatorErrorHook, + Operators.KEY_ON_REJECTED_EXECUTION, localReeHook); + + IllegalArgumentException failure = new IllegalArgumentException("foo"); + final Throwable throwable = Operators.onRejectedExecution(failure, null, + null, "bar", c); + + assertThat(throwable).isInstanceOf(IllegalStateException.class) + .hasMessage("rejected_bar") + .hasNoSuppressedExceptions(); + assertThat(throwable.getCause()).isInstanceOf(RejectedExecutionException.class) + .hasMessage("Scheduler unavailable") + .hasCause(failure); + } }