Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-9964

UtilMisc.ensureLocale does not always return a valid Locale

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: Trunk, Release Branch 16.11
    • Fix Version/s: 16.11.04
    • Component/s: framework
    • Labels:
      None

      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.

          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();
          }
      

      I will provide a patch for it.

        Attachments

          Activity

            People

            • Assignee:
              mbrohl Michael Brohl
              Reporter:
              mbrohl Michael Brohl
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: