-
Notifications
You must be signed in to change notification settings - Fork 297
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
Validate that timeout is positive in WaitForOrchestrationAsync, and enable nullable checks #910
Merged
davidmrdavid
merged 7 commits into
main
from
dajusto/check-for-negative-timespan-waitForOrchestrationAsync
Jun 2, 2023
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ec2bb43
enable nullable checks and check that timeout is positive in WaitForI…
davidmrdavid cf97739
allow negative timeouts
davidmrdavid ecd3762
explicitly check for infiniteTimeSpan
davidmrdavid 8ca300c
Apply suggestions from code review
davidmrdavid 26cfbd6
refactor to support TimeSpan.Zero
davidmrdavid 76e279d
update param description
davidmrdavid c227c2c
check status after timeout, and refactor loop
davidmrdavid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we accept negative values? There seems to be a precedence that negative implies infinite for timeouts. Especially since
Timeout.InfiniteTimeSpan
is negative.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, I think it's up for debate, and I no strong feelings on this. I simply noticed that the code today assumes the timeout will be positive, and so I made that assumption explicit by validating the input.
Using a combination of
Datetime.now
and the provided timespan, we can modify the currrent implementation to work with infinite timespans as well.Would you prefer if we accepted negative timespans? I see no issue with that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be a better experience to accept negative as an infinite timeout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say let's be specific and allow for
Timeout.InfiniteTimeSpan
to mean infinite, whereas we throw for any other negative value. I believe this is mostly consistent with other .NET APIs and helps us differentiate an explicit desire for infinite vs. an accidental negative value provided by the user.So here, I think we'd say
if (timeout < TimeSpan.Zero && timeout != Timeout.InfiniteTimeSpan)
and below, we change the while loop condition to bewhile (!cancellationToken.IsCancellationRequested)
(removing thetimeout
check).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the compromise of explicitly checking for
Timeout.InfiniteTimeSpan
, and erroring out in other negativeTimeSpan
cases. My latest commit tries to do just that.My if statement is as you suggested, @cgillum. However, the while loop does preserve the timeout check because I think we need it for the "happy case" where the timeout is positive. I suppose I could also move it to an if-statement check inside the while loop though.