Remove dead ThrowIfCancellationRequested() in WaitForFullBootAsync#363
Open
jonathanpeppers wants to merge 2 commits intomainfrom
Open
Remove dead ThrowIfCancellationRequested() in WaitForFullBootAsync#363jonathanpeppers wants to merge 2 commits intomainfrom
jonathanpeppers wants to merge 2 commits intomainfrom
Conversation
The while (!cancellationToken.IsCancellationRequested) loop condition already guarantees the token is not cancelled at the start of each iteration, making the immediate ThrowIfCancellationRequested() call unreachable. Actual cancellation propagates via OperationCanceledException from the awaited adb call and Task.Delay. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Removes an in-loop cancellation check in EmulatorRunner.WaitForFullBootAsync, aiming to simplify the boot polling loop used by the Android SDK tooling.
Changes:
- Removed an in-loop
cancellationToken.ThrowIfCancellationRequested()call from the boot polling loop. - Adjusted the polling loop body accordingly (but introduced a minor formatting issue).
| cancellationToken.ThrowIfCancellationRequested (); | ||
|
|
||
| var bootCompleted = await adbRunner.GetShellPropertyAsync (serial, "sys.boot_completed", cancellationToken).ConfigureAwait (false); | ||
| var bootCompleted= await adbRunner.GetShellPropertyAsync (serial, "sys.boot_completed", cancellationToken).ConfigureAwait (false); |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The while (!cancellationToken.IsCancellationRequested) loop condition in WaitForFullBootAsync already guarantees the token is not cancelled at the start of each iteration. The immediately following cancellationToken.ThrowIfCancellationRequested() call was therefore unreachable dead code — it could never throw.
Actual cancellation propagates correctly via OperationCanceledException thrown by the awaited adb call and Task.Delay(..., cancellationToken) when the token fires asynchronously.
The redundant check also misled readers into thinking it provided an extra cancellation checkpoint, when in reality it added nothing.
Changes
No behavior change
Cancellation behavior is identical — Task.Delay and the awaited adb calls already handle it.