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

Redundant checks in ResponseCachingKeyProvider #59537

Open
leeriorio opened this issue Dec 18, 2024 · 0 comments
Open

Redundant checks in ResponseCachingKeyProvider #59537

leeriorio opened this issue Dec 18, 2024 · 0 comments
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware

Comments

@leeriorio
Copy link

There are two places, where Null-Conditional Operator (?.) using seems redundant in CreateStorageVaryByKey() method of internal class ResponseCachingKeyProvider.

var headersCount = varyByRules?.Headers.Count ?? 0;

and

There is sufficient check of varyByRules value at the start of the method. Isn't it?

if (varyByRules == null)
{
throw new InvalidOperationException($"{nameof(CachedVaryByRules)} must not be null on the {nameof(ResponseCachingContext)}");
}

Found by Linux Verification Center (linuxtesting.org) with SVACE.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware
Projects
None yet
Development

No branches or pull requests

1 participant