From 0f5f659b48deba4ab782d5427ae52c2bb64de667 Mon Sep 17 00:00:00 2001 From: tanghc Date: Wed, 3 Feb 2021 11:45:19 +0800 Subject: [PATCH] 4.2.5 --- .../com/gitee/sop/gatewaycommon/message/ErrorFactory.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java index 98d33f98..f0236808 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java @@ -7,6 +7,7 @@ import org.springframework.context.support.ResourceBundleMessageSource; import org.springframework.util.Assert; import org.springframework.util.StringUtils; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -33,6 +34,8 @@ public class ErrorFactory { private static Map errorCache = new HashMap<>(64); + private static List localeList = Arrays.asList(Locale.ENGLISH, Locale.SIMPLIFIED_CHINESE); + /** * 错误信息的国际化信息 */ @@ -70,6 +73,9 @@ public class ErrorFactory { if (locale == null) { locale = Locale.SIMPLIFIED_CHINESE; } + if (!localeList.contains(locale)) { + locale = Locale.ENGLISH; + } String key = errorMeta.getModulePrefix() + errorMeta.getCode() + errorMeta.getSubCode() + locale.toString(); Error error = errorCache.get(key); if (error == null) {