Skip to content

Remove IsAvailable check on CommitAsync. #43059

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

Merged
Merged
Changes from all commits
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
6 changes: 0 additions & 6 deletions src/Middleware/Session/src/DistributedSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,6 @@ public async Task LoadAsync(CancellationToken cancellationToken = default)
/// <inheritdoc />
public async Task CommitAsync(CancellationToken cancellationToken = default)
{
if (!IsAvailable)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// use field to avoid loading the session via IsAvailable property
if (!_isAvailable)

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we want that; if _isAvailable wasn't set, it could be that we never attempted to load it. The current code attempts to load in that case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we remove this check in CommitAsync but not in Set?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set always depends on IsAvailable, but CommitAsync might not need to load the session if _isModified isn't true. The IsAvailable check was added in CommitAsync during the nullability work but I don't see why it's necessary now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. And it could force sync-over-async as well. Yuck!

{
_logger.SessionNotAvailable();
return;
}

using (var timeout = new CancellationTokenSource(_ioTimeout))
{
var cts = CancellationTokenSource.CreateLinkedTokenSource(timeout.Token, cancellationToken);
Expand Down