From ce540ef97b54a4c4e5eef3876009b45481567df9 Mon Sep 17 00:00:00 2001 From: Yvan Date: Wed, 9 Sep 2020 17:50:19 +0800 Subject: [PATCH 1/5] =?UTF-8?q?REPORT-39341=20=E3=80=90=E5=9B=9E=E5=BD=92?= =?UTF-8?q?=E3=80=91=E3=80=90jdk11=E3=80=91=E6=96=87=E4=BB=B6=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E8=AF=BB=E5=86=99=E6=9D=83=E9=99=90=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E6=98=AF=E8=8B=B1=E6=96=87=201.=20bug?= =?UTF-8?q?=E5=8E=9F=E5=9B=A0=EF=BC=9A=E5=9C=A8=E4=B8=AD=E6=96=87=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E4=B8=8B=EF=BC=8C=E8=BF=99=E8=BE=B9=E4=BC=A0=E8=BF=87?= =?UTF-8?q?=E6=9D=A5=E7=9A=84Locale=E6=98=AFzh-Hans-CN=EF=BC=8C=E8=BF=9B?= =?UTF-8?q?=E5=85=A5isSupport=E6=96=B9=E6=B3=95=E4=B8=AD=E6=97=B6=E4=BC=9A?= =?UTF-8?q?=E5=8F=91=E7=8E=B0=E4=B8=8D=E5=8C=B9=E9=85=8D=EF=BC=8C=E7=84=B6?= =?UTF-8?q?=E5=90=8ELocale=E8=A2=AB=E8=AE=BE=E7=BD=AE=E6=88=90en=5FUS?= =?UTF-8?q?=EF=BC=8C=E7=84=B6=E5=90=8E=E5=9C=A8=E6=8A=A5=E9=94=99=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E9=87=8C=E9=9D=A2=E7=9A=84=E5=86=85=E5=AE=B9=E5=B0=B1?= =?UTF-8?q?=E9=83=BD=E6=98=AF=E8=8B=B1=E6=96=87=E4=BA=86=202.=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=96=B9=E6=A1=88=EF=BC=9A=E5=A2=9E=E5=8A=A0=E5=88=A4?= =?UTF-8?q?=E6=96=AD=EF=BC=8C=E5=B0=86=E4=BC=A0=E8=BF=87=E6=9D=A5=E7=9A=84?= =?UTF-8?q?Locale=E7=9A=84script=E6=8A=B9=E5=8E=BB=EF=BC=8C=E5=8F=AA?= =?UTF-8?q?=E4=BF=9D=E7=95=99language=E5=92=8Cregion=EF=BC=8C=E8=B7=9F?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=87=8C=E9=9D=A2=E4=BF=9D=E5=AD=98=E7=9A=84?= =?UTF-8?q?Locale=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/DesignerEnvManager.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 88d2625d02..375e40e4c0 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -163,7 +163,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * alphafine */ private AlphaFineConfigManager alphaFineConfigManager = AlphaFineConfigManager.getInstance(); - + /** * 阅后即焚的配置项 */ @@ -1424,6 +1424,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * @return */ private Locale checkLocale(Locale locale) { + // Yvan: REPORT-39341,有一些情况下,获取到的是zh-Hans-CN,转成zh_CN + if (locale != null) { + locale = new Locale(locale.getLanguage(), locale.getCountry()); + } return SupportLocale.getInstance().isSupport(locale) ? locale : Locale.US; } @@ -1578,7 +1582,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } } } - + private void readSnapChatConfig(XMLableReader reader) { reader.readXMLObject(this.snapChatConfig = SnapChatConfig.getInstance()); } @@ -1801,14 +1805,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { writeSnapChatConfig(writer); writer.end(); } - + private void writeSnapChatConfig(XMLPrintWriter writer) { - + if (this.snapChatConfig != null) { this.snapChatConfig.writeXML(writer); } } - + private void writeAlphaFineAttr(XMLPrintWriter writer) { if (this.alphaFineConfigManager != null) { this.alphaFineConfigManager.writeXML(writer); From ba7a9e3aa8f1d381b442272dec823f84828fca18 Mon Sep 17 00:00:00 2001 From: Yvan Date: Wed, 9 Sep 2020 18:56:46 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/java/com/fr/design/DesignerEnvManagerTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java b/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java index b7d123d66e..1e16a1d7c9 100644 --- a/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java +++ b/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java @@ -1,5 +1,6 @@ package com.fr.design; +import com.fr.invoke.Reflect; import junit.framework.TestCase; import java.util.Locale; @@ -17,4 +18,10 @@ public class DesignerEnvManagerTest extends TestCase{ assertEquals("下边界", envManager.getLanguage(), Locale.SIMPLIFIED_CHINESE); } + + public void testCheckLocale() { + DesignerEnvManager envManager = new DesignerEnvManager(); + Locale checkLocale = Reflect.on(envManager).call("checkLocale", Locale.getDefault()).get(); + assertEquals(Locale.SIMPLIFIED_CHINESE, checkLocale); + } } From 63ce4a6d720af6085aee9bf1eac849b3337769f3 Mon Sep 17 00:00:00 2001 From: Yvan Date: Thu, 10 Sep 2020 14:56:43 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManagerTest.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java b/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java index 1e16a1d7c9..2707d73dd5 100644 --- a/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java +++ b/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java @@ -2,6 +2,7 @@ package com.fr.design; import com.fr.invoke.Reflect; import junit.framework.TestCase; +import org.easymock.EasyMock; import java.util.Locale; @@ -20,8 +21,18 @@ public class DesignerEnvManagerTest extends TestCase{ } public void testCheckLocale() { - DesignerEnvManager envManager = new DesignerEnvManager(); - Locale checkLocale = Reflect.on(envManager).call("checkLocale", Locale.getDefault()).get(); - assertEquals(Locale.SIMPLIFIED_CHINESE, checkLocale); + DesignerEnvManager envManager = EasyMock.createMock(DesignerEnvManager.class); + Reflect on = Reflect.on(envManager); + + //验证zh-Hans-CN + Locale locale = Reflect.on(Locale.class).call("getInstance", "zh", "", "CN", "", null).get(); + assertEquals(Locale.SIMPLIFIED_CHINESE, locale); + + //验证其它语言 + assertEquals(Locale.SIMPLIFIED_CHINESE, on.call("checkLocale", Locale.SIMPLIFIED_CHINESE).get()); + assertEquals(Locale.TRADITIONAL_CHINESE, on.call("checkLocale", Locale.TRADITIONAL_CHINESE).get()); + assertEquals(Locale.US, on.call("checkLocale", Locale.US).get()); + assertEquals(Locale.JAPAN, on.call("checkLocale", Locale.JAPAN).get()); + assertEquals(Locale.KOREA, on.call("checkLocale", Locale.KOREA).get()); } } From 19e4eb426f4cc8c96725db25b3ac9143d508b758 Mon Sep 17 00:00:00 2001 From: Yvan Date: Thu, 10 Sep 2020 15:00:35 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/java/com/fr/design/DesignerEnvManagerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java b/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java index 2707d73dd5..f1e9915793 100644 --- a/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java +++ b/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java @@ -26,7 +26,7 @@ public class DesignerEnvManagerTest extends TestCase{ //验证zh-Hans-CN Locale locale = Reflect.on(Locale.class).call("getInstance", "zh", "", "CN", "", null).get(); - assertEquals(Locale.SIMPLIFIED_CHINESE, locale); + assertEquals(Locale.SIMPLIFIED_CHINESE, on.call("checkLocale", locale).get()); //验证其它语言 assertEquals(Locale.SIMPLIFIED_CHINESE, on.call("checkLocale", Locale.SIMPLIFIED_CHINESE).get()); From fe6973e495f9b322690a60eb8dce29f2f724f0ea Mon Sep 17 00:00:00 2001 From: Yvan Date: Thu, 10 Sep 2020 16:02:08 +0800 Subject: [PATCH 5/5] =?UTF-8?q?REPORT-39341=20=E3=80=90=E5=9B=9E=E5=BD=92?= =?UTF-8?q?=E3=80=91=E6=96=87=E4=BB=B6=E6=B2=A1=E6=9C=89=E8=AF=BB=E5=86=99?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=8A=A5=E5=91=8A=E5=BC=B9=E7=AA=97=E6=98=AF?= =?UTF-8?q?=E8=8B=B1=E6=96=87=20=E4=BF=AE=E6=94=B9=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E6=96=B9=E6=A1=88=EF=BC=9A=E7=BB=8F=E8=BF=87=E5=A4=9A=E4=BD=8D?= =?UTF-8?q?=E5=A4=A7=E4=BD=AC=E6=8F=90=E9=86=92=EF=BC=8C=E6=9C=80=E5=A5=BD?= =?UTF-8?q?=E4=B8=8D=E8=A6=81=E7=9B=B4=E6=8E=A5=E4=BF=AE=E6=94=B9=E4=BC=A0?= =?UTF-8?q?=E8=BF=87=E6=9D=A5=E7=9A=84Locale=EF=BC=8C=E5=9B=A0=E6=AD=A4?= =?UTF-8?q?=E8=BD=AC=E5=8F=98=E6=80=9D=E8=B7=AF=E4=B8=BA=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=8E=A5=E6=94=B6=E5=88=B0=E4=BA=86=E6=AF=94=E8=BE=83=E5=A5=87?= =?UTF-8?q?=E6=80=AA=E7=9A=84Locale=EF=BC=8C=E5=B0=BD=E9=87=8F=E6=89=BE?= =?UTF-8?q?=E5=88=B0=E4=B8=80=E4=B8=AA=E5=9C=A8=E6=9C=AC=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=B8=AD=E4=BD=BF=E7=94=A8=E7=9A=84=E6=9C=80=E6=8E=A5=E8=BF=91?= =?UTF-8?q?=E7=9A=84Locale=E8=BF=94=E5=9B=9E=EF=BC=8C=E5=A6=82=E4=BC=A0?= =?UTF-8?q?=E5=85=A5=E5=8F=82=E6=95=B0=E4=B8=BAzh-Hans-CN=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E8=BF=94=E5=9B=9Ezh=5FCN=EF=BC=8C=E8=80=8C=E4=B8=8D?= =?UTF-8?q?=E6=98=AF=E4=B9=8B=E5=89=8D=E7=9A=84en=5FUS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/DesignerEnvManager.java | 8 +++----- .../com/fr/design/DesignerEnvManagerTest.java | 18 ------------------ 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 375e40e4c0..68bb917114 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -1424,11 +1424,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * @return */ private Locale checkLocale(Locale locale) { - // Yvan: REPORT-39341,有一些情况下,获取到的是zh-Hans-CN,转成zh_CN - if (locale != null) { - locale = new Locale(locale.getLanguage(), locale.getCountry()); - } - return SupportLocale.getInstance().isSupport(locale) ? locale : Locale.US; + // Yvan: REPORT-39341,有一些情况下,获取到的是zh-Hans-CN这种,需要找到项目中最匹配的Locale + return SupportLocale.getInstance().isSupport(locale) ? + locale : SupportLocale.getInstance().getSuitableLocale(locale); } private void readReportLengthUnit(XMLableReader reader) { diff --git a/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java b/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java index f1e9915793..b7d123d66e 100644 --- a/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java +++ b/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java @@ -1,8 +1,6 @@ package com.fr.design; -import com.fr.invoke.Reflect; import junit.framework.TestCase; -import org.easymock.EasyMock; import java.util.Locale; @@ -19,20 +17,4 @@ public class DesignerEnvManagerTest extends TestCase{ assertEquals("下边界", envManager.getLanguage(), Locale.SIMPLIFIED_CHINESE); } - - public void testCheckLocale() { - DesignerEnvManager envManager = EasyMock.createMock(DesignerEnvManager.class); - Reflect on = Reflect.on(envManager); - - //验证zh-Hans-CN - Locale locale = Reflect.on(Locale.class).call("getInstance", "zh", "", "CN", "", null).get(); - assertEquals(Locale.SIMPLIFIED_CHINESE, on.call("checkLocale", locale).get()); - - //验证其它语言 - assertEquals(Locale.SIMPLIFIED_CHINESE, on.call("checkLocale", Locale.SIMPLIFIED_CHINESE).get()); - assertEquals(Locale.TRADITIONAL_CHINESE, on.call("checkLocale", Locale.TRADITIONAL_CHINESE).get()); - assertEquals(Locale.US, on.call("checkLocale", Locale.US).get()); - assertEquals(Locale.JAPAN, on.call("checkLocale", Locale.JAPAN).get()); - assertEquals(Locale.KOREA, on.call("checkLocale", Locale.KOREA).get()); - } }