Skip to content

Commit 69f3db7

Browse files
authored
Fix MsQuicConfiguration.GetConfigurationCacheEnabled (#101555)
1 parent e1fe97a commit 69f3db7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicConfiguration.Cache.cs

+7-6
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,23 @@ internal static partial class MsQuicConfiguration
2121
private const string DisableCacheCtxSwitch = "System.Net.Quic.DisableConfigurationCache";
2222

2323
internal static bool ConfigurationCacheEnabled { get; } = GetConfigurationCacheEnabled();
24+
2425
private static bool GetConfigurationCacheEnabled()
2526
{
2627
// AppContext switch takes precedence
2728
if (AppContext.TryGetSwitch(DisableCacheCtxSwitch, out bool value))
2829
{
2930
return !value;
3031
}
31-
else
32+
// check environment variable second
33+
else if (Environment.GetEnvironmentVariable(DisableCacheEnvironmentVariable) is string envVar)
3234
{
33-
// check environment variable
34-
return
35-
Environment.GetEnvironmentVariable(DisableCacheEnvironmentVariable) is string envVar &&
36-
!(envVar == "1" || envVar.Equals("true", StringComparison.OrdinalIgnoreCase));
35+
return !(envVar == "1" || envVar.Equals("true", StringComparison.OrdinalIgnoreCase));
3736
}
38-
}
3937

38+
// enabled by default
39+
return true;
40+
}
4041
private static readonly ConcurrentDictionary<CacheKey, MsQuicConfigurationSafeHandle> s_configurationCache = new();
4142

4243
private readonly struct CacheKey : IEquatable<CacheKey>

0 commit comments

Comments
 (0)