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

Fix unused TimeoutStrategy parameter #823

Merged

Conversation

martincostello
Copy link
Member

The issue or feature being addressed

Fix the timeoutStrategy parameter not being used by Policy.TimeoutAsync<TResult>(Func<TimeSpan>, TimeoutStrategy, Func<Context, TimeSpan, Task, Task>) which meant that TimeoutStrategy.Optimistic was always being used.

I found this issue when experimenting with whether it was worth adding a net5.0 TFM to Polly (TL;DR - I don't think it is) and enabling the new .NET analyzers built into the .NET 5.0 SDK. Doing that flagged up the unused parameter as a CA1801 warning.

Details on the issue fix or feature implementation

Pass the parameter value to Policy.TimeoutAsync<TResult>(Func<Context, TimeSpan>, TimeoutStrategy, Func<Context, TimeSpan, Task, Task>).

I did try to come up with a unit test that verified the wrong strategy was being used pre-fix, but I got stuck with the custom clock implementation in the tests and couldn't get a test using a never-completing callback to not hang forever.

Confirm the following

  • I started this PR by branching from the head of the latest dev vX.Y branch, or I have rebased on the latest dev vX.Y branch, or I have merged the latest changes from the dev vX.Y branch
  • I have targeted the PR to merge into the latest dev vX.Y branch as the base branch
  • I have included unit tests for the issue/feature
  • I have successfully run a local build

Fix the timeoutStrategy parameter not being used.
@martincostello martincostello added this to the v7.2.2 milestone Jan 24, 2021
@martincostello martincostello self-assigned this Jan 24, 2021
@martincostello martincostello merged commit 5afd3a8 into App-vNext:v722-or-v730 Jan 25, 2021
@martincostello martincostello deleted the Use-TimeoutStrategy branch January 25, 2021 17:00
@martincostello martincostello mentioned this pull request Apr 11, 2021
4 tasks
martincostello added a commit that referenced this pull request Apr 11, 2021
Fix the timeoutStrategy parameter not being used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant