Uploaded image for project: 'Hippo Site Toolkit 2'
  1. Hippo Site Toolkit 2
  2. HSTTWO-1789

HippoDocument#getLocale should not throw an exception when the locale is invalid

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 2.22.03
    • Fix Version/s: 2.22.04, 2.23.03
    • Component/s: None
    • Labels:
      None
    • Similar issues:

      Description

      HippoDocument#getLocale is using LocaleUtils#toLocale. This method throws an IllegalArgumentException when the locale is not null and invalid.

      I encountered a problem when the folder locale was missing, and the documents created in this folder had the invalid locale 'document-type-locale'. It was breaking some pages on the website.

      So I think it would be safer to catch and log this exception. My proposition:

      public Locale getLocale() {
      String localeString = getLocaleString();
      try

      { return LocaleUtils.toLocale(localeString); }

      catch(IllegalArgumentException e)

      { log.warn("Invalid locale " + localeString + " for document " + getPath(), e); }

      return null;
      }

        Attachments

          Activity

            People

            • Assignee:
              aschrijvers Ard Schrijvers
              Reporter:
              mtricot Mickaƫl Tricot (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: