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

UtilMisc.ensureLocale does not always return a valid Locale

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • Release Branch 16.11, Trunk
    • 16.11.04
    • framework
    • 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

        1. OFBIZ-9964_ensureLocale.patch
          0.8 kB
          Michael Brohl

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: