From 25d7281209253c7a8e846e2011a7d70a4f764255 Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 28 May 2025 11:26:22 +0800 Subject: [PATCH] fix(localization): Fix the potential stamp cache expiration null reference exception --- .../External/ExternalLocalizationTextStoreCache.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/External/ExternalLocalizationTextStoreCache.cs b/aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/External/ExternalLocalizationTextStoreCache.cs index 1a216363f..c56e203b2 100644 --- a/aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/External/ExternalLocalizationTextStoreCache.cs +++ b/aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/External/ExternalLocalizationTextStoreCache.cs @@ -84,14 +84,15 @@ public class ExternalLocalizationTextStoreCache : IExternalLocalizationTextStore var stampCacheKey = ExternalLocalizationTextStampCacheItem.CalculateCacheKey(resource.ResourceName, cultureName); var stampCacheItem = await StampCache.GetAsync(stampCacheKey); - if (memoryCacheItem != null && memoryCacheItem.CacheStamp == stampCacheItem.Stamp) + + if (memoryCacheItem != null && memoryCacheItem.CacheStamp == stampCacheItem?.Stamp) { memoryCacheItem.LastCheckTime = DateTime.Now; return memoryCacheItem.Texts; } var distributeCacheItem = await DistributedCache.GetAsync(cacheKey); - if (distributeCacheItem != null) + if (stampCacheItem != null && distributeCacheItem != null) { MemoryCache[cacheKey] = new LocalizationTextMemoryCacheItem(distributeCacheItem.Texts, stampCacheItem.Stamp);