Skip to content

Commit

Permalink
Fix failing hedging test in Debug (#2321)
Browse files Browse the repository at this point in the history
Resolves #2315.
  • Loading branch information
peter-csala authored Oct 1, 2024
1 parent 056b27c commit 74ac188
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ private void UpdateOriginalContext()
return;
}

Debug.Assert(Tasks.Count(t => t.IsAccepted) == 1, $"There must be exactly one accepted outcome for hedging. Found {Tasks.Count(t => t.IsAccepted)}.");

if (Tasks.FirstOrDefault(static t => t.IsAccepted) is TaskExecution<T> acceptedExecution)
{
PrimaryContext!.Properties.AddOrReplaceProperties(acceptedExecution.Context.Properties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ public async Task ExecuteAsync_EnsureBackgroundWorkInSuccessfulCallNotCancelled(
await Assert.ThrowsAsync<TaskCanceledException>(() => backgroundTasks[0]);

// background task is still pending
Assert.False(backgroundTasks[1].IsCompleted);
backgroundTasks[1].IsCompleted.Should().BeFalse();

cts.Cancel();

Expand Down Expand Up @@ -670,7 +670,7 @@ public async Task ExecuteAsync_ZeroHedgingDelay_EnsureAllTasksSpawnedAtOnce()
var task = Create().ExecuteAsync(async c => (await Execute(c)).Result!, default);

// assert
Assert.True(allExecutionsReached.WaitOne(AssertTimeout));
allExecutionsReached.WaitOne(AssertTimeout).Should().BeTrue();
_timeProvider.Advance(LongDelay);
await task;

Expand Down Expand Up @@ -699,7 +699,7 @@ public void ExecuteAsync_InfiniteHedgingDelay_EnsureNoConcurrentExecutions()
var pending = Create().ExecuteAsync(Execute, _cts.Token);

// assert
Assert.True(allExecutions.WaitOne(AssertTimeout));
allExecutions.WaitOne(AssertTimeout).Should().BeTrue();

async ValueTask<string> Execute(CancellationToken token)
{
Expand Down

0 comments on commit 74ac188

Please sign in to comment.