Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Fix chaos outcome exception handling #2101

Merged
merged 8 commits into from
May 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@
await _onOutcomeInjected(args).ConfigureAwait(context.ContinueOnCapturedContext);
}

if (outcome.Value.Exception is not null)
if (outcome.HasValue is false)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / macos-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / macos-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / macos-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / macos-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check failure on line 34 in src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
martincostello marked this conversation as resolved.
Show resolved Hide resolved
{
return new Outcome<T>(outcome.Value.Exception);
return new Outcome<T>(default(T?));
}

return new Outcome<T>(outcome.Value.Result);
if (outcome.Value.HasResult)
{
return new Outcome<T>(outcome.Value.Result);
}

return new Outcome<T>(outcome.Value.Exception!);
}

return await StrategyHelper.ExecuteCallbackSafeAsync(callback, context, state).ConfigureAwait(context.ContinueOnCapturedContext);
Expand Down
Loading