From dd7ab2f647fb2910371b48d1c7b7791eccd2b53a Mon Sep 17 00:00:00 2001 From: Nicolas Dorier Date: Thu, 18 Jan 2024 09:31:35 +0900 Subject: [PATCH] Avoid exception storm when currency provider is initialized (#5668) --- BTCPayServer.Rating/CurrencyNameTable.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/BTCPayServer.Rating/CurrencyNameTable.cs b/BTCPayServer.Rating/CurrencyNameTable.cs index f26279301..04560fc90 100644 --- a/BTCPayServer.Rating/CurrencyNameTable.cs +++ b/BTCPayServer.Rating/CurrencyNameTable.cs @@ -64,8 +64,17 @@ namespace BTCPayServer.Services.Rates { if (_CurrencyProviders.Count == 0) { - foreach (var culture in CultureInfo.GetCultures(CultureTypes.AllCultures).Where(c => !c.IsNeutralCulture)) + foreach (var culture in CultureInfo.GetCultures(CultureTypes.AllCultures)) { + // This avoid storms of exception throwing slowing up + // startup and debugging sessions + if (culture switch + { + { LCID: 0x007F or 0x0000 or 0x0c00 or 0x1000 } => true, + { IsNeutralCulture : true } => true, + _ => false + }) + continue; try { _CurrencyProviders.TryAdd(new RegionInfo(culture.LCID).ISOCurrencySymbol, culture);