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

Uwe Schindler edited comment on LUCENE-6978 at 1/15/16 1:02 PM:
----------------------------------------------------------------

First patch with LTC changes only. I will now work on the forbidden stuff 
(where we may need to fix some other Lucene code parts which try to parse 
locales or print them).

This patch requires Java 8. We can backport (which I suggest), but the streams 
API need to be replaced by a more verbose list-sort-addSet-toArray sequence in 
a {{static}} block.


was (Author: thetaphi):
First patch with LTC changes only. I will now work on the forbidden stuff 
(where we may need to fix some other Lucene code parts which try to parse 
locales or print them).

> Make LuceneTestCase use language tags instead of parsing locales by hand
> ------------------------------------------------------------------------
>
>                 Key: LUCENE-6978
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6978
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: modules/test-framework
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: Trunk
>
>         Attachments: LUCENE-6978.patch
>
>
> Since we are on Java 7, the JDK supports standardized language tags as 
> identifiers for Locales. Previous versions of JDK were missing a constructor 
> from {{Locale#toString()}} back to a locale, so we had our own, which was 
> broken several times after the JDK changed their Locale internals.
> This patch will do the following:
> - When printing the reproduce line, it will use {{Locale#getLanguageTag()}}, 
> so you can identify the locale in standardized form. Most notable change is 
> (next to more flexibility around asian languages) the change away from 
> undescores. So it prints "en-US", not "en_US".
> - The code that parses a locale uses Locale's Builder and sets the language 
> tag. This will fail if the tag is invalid! A trap is 
> {{Locale#forLanguageTag}}, because this one silently returns root locale if 
> unparseable...
> - The random locale is choosen from all language tags, which are extracted 
> from the JDK as a {{String[]}} array.
> I would also like to place {{Locale#forLanguageTag}} on the forbidden list 
> and disallow directly calling {{Locale#toString()}}, the latter is legacy API 
> (according to Java 7 Javadocs). This would fail code that calls toString() 
> directly, e.g. when formatting stuff like {{"my Locale: " + locale}}. Of 
> course we cannot catch all bad uses.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to