[ 
https://issues.apache.org/jira/browse/LANG-1823?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18077460#comment-18077460
 ] 

尹茂椿萱 commented on LANG-1823:
----------------------------

Yes, all test cases pass on the new version. Thanks for the timely fix.

> LocaleUtils.toLocale cannot parse valid JDK Locale string containing '#' 
> (e.g., from Locale.getAvailableLocales())
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: LANG-1823
>                 URL: https://issues.apache.org/jira/browse/LANG-1823
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 3.20.0
>         Environment: java version "1.8.0_202"
>            Reporter: 尹茂椿萱
>            Assignee: Gary D. Gregory
>            Priority: Major
>             Fix For: 3.21.0
>
>
> {{LocaleUtils.toLocale(String)}} claims to strictly validate and convert a 
> locale string into a {{Locale}} object. However, it fails to parse certain 
> valid locale strings produced by the JDK itself.
> Specifically, some {{Locale}} instances returned by 
> {{java.util.Locale#getAvailableLocales()}} produce string representations 
> (via {{{}toString(){}}}) that contain a {{#}} character (e.g., 
> {{{}"th_TH_#Thai"{}}}). These strings cannot be parsed by 
> {{{}LocaleUtils.toLocale{}}}, resulting in an 
> {{{}IllegalArgumentException{}}}.
> This creates an inconsistency where valid JDK locale representations cannot 
> be round-tripped through {{{}LocaleUtils{}}}.
> h3. *Steps to Reproduce*
> import java.util.Locale;
> import org.apache.commons.lang3.LocaleUtils;
> public class Repro {
>     public static void main(String[] args) {
>         for (Locale locale : Locale.getAvailableLocales()) {
>             String str = locale.toString();
>             try {
>                 Locale parsed = LocaleUtils.toLocale(str);
>             } catch (Exception e) {
>                 System.out.println("FAIL: " + str);
>             }
>         }
>     }
> }
>  
> ----
> h3. *Observed Behavior*
> Example failing output:
> {{FAIL: th_TH_#Thai}}
> {{LocaleUtils.toLocale("th_TH_#Thai")}} throws 
> {{{}IllegalArgumentException{}}}.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to