From d62a539a62c0dfcbfbaa214d1e1a6c977cf666ff Mon Sep 17 00:00:00 2001 From: Radek Zikmund <32671551+rzikm@users.noreply.github.com> Date: Thu, 25 Apr 2024 20:54:48 +0200 Subject: [PATCH] Fix MsQuicConfiguration.GetConfigurationCacheEnabled (#101555) --- .../Net/Quic/Internal/MsQuicConfiguration.Cache.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicConfiguration.Cache.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicConfiguration.Cache.cs index 4fc86adfbd1565..38a02cad2328b5 100644 --- a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicConfiguration.Cache.cs +++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicConfiguration.Cache.cs @@ -21,6 +21,7 @@ internal static partial class MsQuicConfiguration private const string DisableCacheCtxSwitch = "System.Net.Quic.DisableConfigurationCache"; internal static bool ConfigurationCacheEnabled { get; } = GetConfigurationCacheEnabled(); + private static bool GetConfigurationCacheEnabled() { // AppContext switch takes precedence @@ -28,15 +29,15 @@ private static bool GetConfigurationCacheEnabled() { return !value; } - else + // check environment variable second + else if (Environment.GetEnvironmentVariable(DisableCacheEnvironmentVariable) is string envVar) { - // check environment variable - return - Environment.GetEnvironmentVariable(DisableCacheEnvironmentVariable) is string envVar && - !(envVar == "1" || envVar.Equals("true", StringComparison.OrdinalIgnoreCase)); + return !(envVar == "1" || envVar.Equals("true", StringComparison.OrdinalIgnoreCase)); } - } + // enabled by default + return true; + } private static readonly ConcurrentDictionary s_configurationCache = new(); private readonly struct CacheKey : IEquatable