[
https://issues.apache.org/jira/browse/OFBIZ-9964?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Brohl updated OFBIZ-9964:
---------------------------------
Description:
The Javadoc promises that the function will always return a valid Locale, at least a default.
This does not work if a String is provided which cannot be parsed to a valid locale through the parseLocale function which can return null.
{code:java}
public static Locale ensureLocale(Object localeObject) {
if (localeObject instanceof String) {
return parseLocale((String) localeObject);
} else if (localeObject instanceof Locale) {
return (Locale) localeObject;
}
return Locale.getDefault();
}
{code}
I will provide a patch for it.
was:
The Javadoc promises that the function will always retirn a valid Locale, at least a default.
This does not work if a String is provided which cannot be parsed to a valid locale through the parseLocale function which can return null.
{code:java}
public static Locale ensureLocale(Object localeObject) {
if (localeObject instanceof String) {
return parseLocale((String) localeObject);
} else if (localeObject instanceof Locale) {
return (Locale) localeObject;
}
return Locale.getDefault();
}
{code}
I will provide a patch for it.
> UtilMisc.ensureLocale does not always return a valid Locale
> -----------------------------------------------------------
>
> Key: OFBIZ-9964
> URL:
https://issues.apache.org/jira/browse/OFBIZ-9964> Project: OFBiz
> Issue Type: Bug
> Components: framework
> Affects Versions: Trunk, Release Branch 16.11
> Reporter: Michael Brohl
> Assignee: Michael Brohl
> Priority: Minor
> Attachments: OFBIZ-9964_ensureLocale.patch
>
>
> The Javadoc promises that the function will always return a valid Locale, at least a default.
> This does not work if a String is provided which cannot be parsed to a valid locale through the parseLocale function which can return null.
> {code:java}
> public static Locale ensureLocale(Object localeObject) {
> if (localeObject instanceof String) {
> return parseLocale((String) localeObject);
> } else if (localeObject instanceof Locale) {
> return (Locale) localeObject;
> }
> return Locale.getDefault();
> }
> {code}
> I will provide a patch for it.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)