From f4e3ab2144f63e3195033e1a33e9d38d012760e6 Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Thu, 25 Apr 2024 18:05:55 +0200 Subject: [PATCH] Fix MsQuicConfiguration.GetConfigurationCacheEnabled --- .../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 4fc86adfbd156..38a02cad2328b 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