@@ -2547,6 +2547,8 @@ private sealed class Logic : InAndOutGraphStageLogic
2547
2547
{
2548
2548
private sealed class Holder < T > ( object ? message , Result < T > element )
2549
2549
{
2550
+ private Directive ? _cachedDirective = null ;
2551
+
2550
2552
public object ? Message { get ; } = message ;
2551
2553
2552
2554
public Result < T > Element { get ; private set ; } = element ;
@@ -2557,6 +2559,12 @@ public void SetElement(Result<T> result)
2557
2559
? Result . Failure < T > ( ReactiveStreamsCompliance . ElementMustNotBeNullException )
2558
2560
: result ;
2559
2561
}
2562
+
2563
+ public Directive SupervisionDirectiveFor ( Decider decider , Exception ex )
2564
+ {
2565
+ _cachedDirective ??= decider ( ex ) ;
2566
+ return _cachedDirective . Value ;
2567
+ }
2560
2568
}
2561
2569
2562
2570
private static readonly Result < TOut > NotYetThere = Result . Failure < TOut > ( new Exception ( ) ) ;
@@ -2673,7 +2681,7 @@ private void PushOne()
2673
2681
{
2674
2682
// this could happen if we are looping in PushOne and end up on a failed Task before the
2675
2683
// HolderCompleted callback has run
2676
- var strategy = _decider ( result . Exception ) ;
2684
+ var strategy = holder . SupervisionDirectiveFor ( _decider , result . Exception ! ) ;
2677
2685
Log . Error ( result . Exception , "An exception occured inside SelectAsync while processing message [{0}]. Supervision strategy: {1}" , holder . Message , strategy ) ;
2678
2686
switch ( strategy )
2679
2687
{
@@ -2720,7 +2728,7 @@ private void HolderCompleted(Holder<TOut> holder, Result<TOut> result)
2720
2728
}
2721
2729
2722
2730
var exception = result . Exception ;
2723
- var strategy = _decider ( exception ) ;
2731
+ var strategy = holder . SupervisionDirectiveFor ( _decider , exception ! ) ;
2724
2732
Log . Error ( exception , "An exception occured inside SelectAsync while executing Task. Supervision strategy: {0}" , strategy ) ;
2725
2733
switch ( strategy )
2726
2734
{
0 commit comments