Skip to content

Commit

Permalink
code coverage fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
martintmk committed Jun 20, 2023
1 parent 5e1b605 commit a44ba44
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal sealed class CircuitStateController<T> : IDisposable
private DateTimeOffset _blockedUntil;
private CircuitState _circuitState = CircuitState.Closed;
private Outcome<object>? _lastOutcome;
private BrokenCircuitException? _breakingException;
private BrokenCircuitException _breakingException = new();
private bool _disposed;

public CircuitStateController(
Expand Down Expand Up @@ -134,8 +134,8 @@ public ValueTask CloseCircuitAsync(ResilienceContext context)

exception = _circuitState switch
{
CircuitState.Open => GetBreakingException_NeedsLock(),
CircuitState.HalfOpen when isHalfOpen is false => GetBreakingException_NeedsLock(),
CircuitState.Open => _breakingException,
CircuitState.HalfOpen when isHalfOpen is false => _breakingException,
CircuitState.Isolated => new IsolatedCircuitException(),
_ => null
};
Expand Down Expand Up @@ -261,7 +261,6 @@ private void CloseCircuit_NeedsLock(Outcome<T> outcome, bool manual, ResilienceC

_blockedUntil = DateTimeOffset.MinValue;
_lastOutcome = null;
_breakingException = null;

CircuitState priorState = _circuitState;
_circuitState = CircuitState.Closed;
Expand Down Expand Up @@ -294,7 +293,6 @@ private bool PermitHalfOpenCircuitTest_NeedsLock()
private void SetLastHandledOutcome_NeedsLock<TResult>(Outcome<TResult> outcome)
{
_lastOutcome = outcome.AsOutcome();
_breakingException = null;

if (outcome.Exception is Exception exception)
{
Expand All @@ -304,12 +302,8 @@ private void SetLastHandledOutcome_NeedsLock<TResult>(Outcome<TResult> outcome)
{
_breakingException = new BrokenCircuitException<TResult>(BrokenCircuitException.DefaultMessage, result!);
}

_breakingException?.TrySetStackTrace();
}

private BrokenCircuitException GetBreakingException_NeedsLock() => _breakingException ?? new BrokenCircuitException();

private void OpenCircuit_NeedsLock(Outcome<T> outcome, bool manual, ResilienceContext context, out Task? scheduledTask)
{
OpenCircuitFor_NeedsLock(outcome, _breakDuration, manual, context, out scheduledTask);
Expand Down
2 changes: 0 additions & 2 deletions src/Polly.Core/OutcomeArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,5 @@ public OutcomeArguments(ResilienceContext context, Outcome<TResult> outcome, TAr
/// Gets the result, if any, produced by the resilience operation or event.
/// </summary>
public TResult? Result => Outcome.Result;

internal OutcomeArguments<object, TArgs> AsObjectArguments() => new(Context, Outcome.AsOutcome(), Arguments);
}
}

0 comments on commit a44ba44

Please sign in to comment.