Philip Mundt created LANG-1260:
----------------------------------
Summary: LocaleUtils.toLocale() produces arbitrary locales
Key: LANG-1260
URL: https://issues.apache.org/jira/browse/LANG-1260
Project: Commons Lang
Issue Type: Bug
Affects Versions: 3.4
Reporter: Philip Mundt
When passing an invalid locale string ({{len != 2 && len != 5 && len < 7}}) to
{{org.apache.commons.lang3.LocaleUtils#toLocale(String)}} the method would
previously (3.1) throw an {{IllegalArgumentException}}.
With version 3.4 the method will – at least for any string with {{len == 3}} –
create an arbitrary locale:
{code}
// GIVEN
String localeString = "xyz";
// WHEN
Locale xyz = LocaleUtils.toLocale(localeString);
// THEN
assertEquals(xyz.toString(), localeString); // What?
{code}
We are relying on this behaviour ({{IllegalArgumentException}}) and were quite
surprised to not find any mention in the changelog.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)