From 9f65083ceede95c3d37d11062f34af51dad2f46e Mon Sep 17 00:00:00 2001 From: Andrei Arlou Date: Wed, 14 Feb 2024 04:33:49 +0200 Subject: [PATCH] Replace deprecated java.util.Locale constructors on factory methods (#8355) --- .../config/tests/module/mappers1/LocaleConfigMapper.java | 4 ++-- .../config/tests/module/mappers2/LocaleConfigMapper.java | 4 ++-- .../tests/mappers1/MapperServicesEnabledOverrideTest.java | 4 ++-- .../config/tests/mappers1/MapperServicesEnabledTest.java | 4 ++-- .../helidon/config/tests/mappers1/MyLocaleConfigMapper.java | 4 ++-- .../config/tests/mappers2/MapperServicesEnabledTest.java | 4 ++-- .../helidon/config/tests/mappers2/MyLocaleConfigMapper.java | 4 ++-- .../jwt/src/main/java/io/helidon/security/jwt/JwtUtil.java | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/config/tests/module-mappers-1-base/src/main/java/io/helidon/config/tests/module/mappers1/LocaleConfigMapper.java b/config/tests/module-mappers-1-base/src/main/java/io/helidon/config/tests/module/mappers1/LocaleConfigMapper.java index bbae542fe1d..e93a7afffa5 100644 --- a/config/tests/module-mappers-1-base/src/main/java/io/helidon/config/tests/module/mappers1/LocaleConfigMapper.java +++ b/config/tests/module-mappers-1-base/src/main/java/io/helidon/config/tests/module/mappers1/LocaleConfigMapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021 Oracle and/or its affiliates. + * Copyright (c) 2017, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ public Locale apply(Config config) throws ConfigMappingException, MissingValueEx String country = config.get("country").asString().orElse(""); String variant = config.get("variant").asString().orElse(""); - return new Locale(language, country, variant); + return Locale.of(language, country, variant); } } diff --git a/config/tests/module-mappers-2-override/src/main/java/io/helidon/config/tests/module/mappers2/LocaleConfigMapper.java b/config/tests/module-mappers-2-override/src/main/java/io/helidon/config/tests/module/mappers2/LocaleConfigMapper.java index 1aa1dd2220b..2b7d31b1e5f 100644 --- a/config/tests/module-mappers-2-override/src/main/java/io/helidon/config/tests/module/mappers2/LocaleConfigMapper.java +++ b/config/tests/module-mappers-2-override/src/main/java/io/helidon/config/tests/module/mappers2/LocaleConfigMapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021 Oracle and/or its affiliates. + * Copyright (c) 2017, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ public Locale apply(Config config) throws ConfigMappingException, MissingValueEx String country = config.get("country").asString().orElse(""); String variant = config.get("variant").asString().orElse(""); - return new Locale("m2:" + language, "m2:" + country, "m2:" + variant); + return Locale.of("m2:" + language, "m2:" + country, "m2:" + variant); } } diff --git a/config/tests/test-mappers-1-common/src/test/java/io/helidon/config/tests/mappers1/MapperServicesEnabledOverrideTest.java b/config/tests/test-mappers-1-common/src/test/java/io/helidon/config/tests/mappers1/MapperServicesEnabledOverrideTest.java index d349927dbbb..de2b53c06fb 100644 --- a/config/tests/test-mappers-1-common/src/test/java/io/helidon/config/tests/mappers1/MapperServicesEnabledOverrideTest.java +++ b/config/tests/test-mappers-1-common/src/test/java/io/helidon/config/tests/mappers1/MapperServicesEnabledOverrideTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021 Oracle and/or its affiliates. + * Copyright (c) 2017, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ public void testLogger() { @Test public void testLocale() { - assertThat(getLocale(), is(new Locale("TEST:cs", "TEST:CZ", "TEST:Praha"))); + assertThat(getLocale(), is(Locale.of("TEST:cs", "TEST:CZ", "TEST:Praha"))); } } diff --git a/config/tests/test-mappers-1-common/src/test/java/io/helidon/config/tests/mappers1/MapperServicesEnabledTest.java b/config/tests/test-mappers-1-common/src/test/java/io/helidon/config/tests/mappers1/MapperServicesEnabledTest.java index 73af348e7e7..b81de9656ed 100644 --- a/config/tests/test-mappers-1-common/src/test/java/io/helidon/config/tests/mappers1/MapperServicesEnabledTest.java +++ b/config/tests/test-mappers-1-common/src/test/java/io/helidon/config/tests/mappers1/MapperServicesEnabledTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021 Oracle and/or its affiliates. + * Copyright (c) 2017, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public void testLogger() { @Test public void testLocale() { - assertThat(getLocale(), is(new Locale("cs", "CZ", "Praha"))); + assertThat(getLocale(), is(Locale.of("cs", "CZ", "Praha"))); } } diff --git a/config/tests/test-mappers-1-common/src/test/java/io/helidon/config/tests/mappers1/MyLocaleConfigMapper.java b/config/tests/test-mappers-1-common/src/test/java/io/helidon/config/tests/mappers1/MyLocaleConfigMapper.java index f6b1be7b965..9a6bbd6f76b 100644 --- a/config/tests/test-mappers-1-common/src/test/java/io/helidon/config/tests/mappers1/MyLocaleConfigMapper.java +++ b/config/tests/test-mappers-1-common/src/test/java/io/helidon/config/tests/mappers1/MyLocaleConfigMapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021 Oracle and/or its affiliates. + * Copyright (c) 2017, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ public Locale apply(Config config) throws ConfigMappingException, MissingValueEx String country = config.get("country").asString().orElse(""); String variant = config.get("variant").asString().orElse(""); - return new Locale("TEST:" + language, "TEST:" + country, "TEST:" + variant); + return Locale.of("TEST:" + language, "TEST:" + country, "TEST:" + variant); } } diff --git a/config/tests/test-mappers-2-complex/src/test/java/io/helidon/config/tests/mappers2/MapperServicesEnabledTest.java b/config/tests/test-mappers-2-complex/src/test/java/io/helidon/config/tests/mappers2/MapperServicesEnabledTest.java index 39fcbc8163c..e2e9dddf14b 100644 --- a/config/tests/test-mappers-2-complex/src/test/java/io/helidon/config/tests/mappers2/MapperServicesEnabledTest.java +++ b/config/tests/test-mappers-2-complex/src/test/java/io/helidon/config/tests/mappers2/MapperServicesEnabledTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021 Oracle and/or its affiliates. + * Copyright (c) 2017, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ public void testLogger() { */ @Test public void testLocale() { - assertThat(getLocale(), is(new Locale("m2:cs", "m2:CZ", "m2:Praha"))); + assertThat(getLocale(), is(Locale.of("m2:cs", "m2:CZ", "m2:Praha"))); } } diff --git a/config/tests/test-mappers-2-complex/src/test/java/io/helidon/config/tests/mappers2/MyLocaleConfigMapper.java b/config/tests/test-mappers-2-complex/src/test/java/io/helidon/config/tests/mappers2/MyLocaleConfigMapper.java index da3f8094fb2..0467986adb0 100644 --- a/config/tests/test-mappers-2-complex/src/test/java/io/helidon/config/tests/mappers2/MyLocaleConfigMapper.java +++ b/config/tests/test-mappers-2-complex/src/test/java/io/helidon/config/tests/mappers2/MyLocaleConfigMapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021 Oracle and/or its affiliates. + * Copyright (c) 2017, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ public Locale apply(Config config) throws ConfigMappingException, MissingValueEx String country = config.get("country").asString().get(); String variant = config.get("variant").asString().get(); - return new Locale("TEST:" + language, "TEST:" + country, "TEST:" + variant); + return Locale.of("TEST:" + language, "TEST:" + country, "TEST:" + variant); } } diff --git a/security/jwt/src/main/java/io/helidon/security/jwt/JwtUtil.java b/security/jwt/src/main/java/io/helidon/security/jwt/JwtUtil.java index 1b3eb631228..8a5ddf39722 100644 --- a/security/jwt/src/main/java/io/helidon/security/jwt/JwtUtil.java +++ b/security/jwt/src/main/java/io/helidon/security/jwt/JwtUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022 Oracle and/or its affiliates. + * Copyright (c) 2018, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -297,7 +297,7 @@ private static Locale toLocale(String locale) { Matcher matcher = LOCALE_PATTERN.matcher(locale); Locale result; if (matcher.matches()) { - result = new Locale(matcher.group(1), matcher.group(2)); + result = Locale.of(matcher.group(1), matcher.group(2)); } else { result = Locale.forLanguageTag(locale); }