Skip to content

Redundant checks in ResponseCachingKeyProvider #59537

Open
@leeriorio

Description

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.

Metadata

Assignees

No one assigned

    Labels

    area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlesware

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions