dotnet / dotnet/aspnetcore

Redundant checks in ResponseCachingKeyProvider

Open
#59,537 1 comment 0 reactions 0 assignees View on GitHub
area-middleware
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

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

https://github.com/dotnet/aspnetcore/blob/6ae3ea387b20f6497b82897d613e9b8a6e31d69c/src/Middleware/ResponseCaching/src/ResponseCachingKeyProvider.cs#L99

and

https://github.com/dotnet/aspnetcore/blob/6ae3ea387b20f6497b82897d613e9b8a6e31d69c/src/Middleware/ResponseCaching/src/ResponseCachingKeyProvider.cs#L126

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

https://github.com/dotnet/aspnetcore/blob/6ae3ea387b20f6497b82897d613e9b8a6e31d69c/src/Middleware/ResponseCaching/src/ResponseCachingKeyProvider.cs#L80-L83

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.